/** * 版权所有:版权所有(C) 2020，卓信科技 * 系统名称:FOL2020-财务在线 * 文件名称:FolFinaBillServiceImpl.java * 模块名称:FolFinaBill逻辑层 * 创建日期:2020年07月31日 上午09:41:49 * 作        者:wangyihan * 内容摘要:与fol_fina_bill表相关业务逻辑 */package com.zx.emanage.postLoanManage.service.impl;import java.math.BigDecimal;import java.sql.Timestamp;import java.text.DecimalFormat;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date;import java.util.HashMap;import java.util.List;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.apache.commons.lang3.StringUtils;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transactional;import org.springframework.transaction.interceptor.TransactionAspectSupport;import org.springframework.util.CollectionUtils;import org.springframework.util.LinkedMultiValueMap;import org.springframework.util.MultiValueMap;import org.springframework.web.client.RestTemplate;import com.alibaba.fastjson.JSON;import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject;import com.alibaba.fastjson.TypeReference;import com.zx.emanage.postLoanManage.persist.FolApplyBillRelationDao;import com.zx.emanage.postLoanManage.persist.FolCreApprovalInfoDao;import com.zx.emanage.postLoanManage.persist.FolFinaBillBusinessTripDetailDao;import com.zx.emanage.postLoanManage.persist.FolFinaBillDao;import com.zx.emanage.postLoanManage.persist.FolFinaBillReimLoanRelationDao;import com.zx.emanage.postLoanManage.persist.FolFinaBillReimburseDetailDao;import com.zx.emanage.postLoanManage.persist.FolFinaBillSubsidiaryDao;import com.zx.emanage.postLoanManage.persist.FolFinaCollectionPayConfirmDao;import com.zx.emanage.postLoanManage.persist.FolFinaLoanRelatedBillDao;import com.zx.emanage.postLoanManage.service.IFolApplyBillRelationService;import com.zx.emanage.postLoanManage.service.IFolFinaBillService;import com.zx.emanage.postLoanManage.service.SendWechatEmailMsgService;import com.zx.emanage.postLoanManage.vo.FolFileBeanVO;import com.zx.emanage.postLoanManage.vo.FolFinaBillSearchBeanVO;import com.zx.emanage.postLoanManage.vo.FolmAbortToMeBeanVO;import com.zx.emanage.postLoanManage.vo.FolmDataBeanVO;import com.zx.emanage.sysmanage.persist.DistrictDao;import com.zx.emanage.sysmanage.persist.FolFileInfoDao;import com.zx.emanage.sysmanage.persist.SysDictMapper;import com.zx.emanage.user.persist.PmPersonnelDao;import com.zx.emanage.user.service.IUserService;import com.zx.emanage.user.vo.PmPersonnel;import com.zx.emanage.util.gen.CodeNoUtil;import com.zx.emanage.util.gen.FOLMsgInfo;import com.zx.emanage.util.gen.GlobalVal;import com.zx.emanage.util.gen.ResultHelper;import com.zx.emanage.util.gen.entity.FolApplyBillRelation;import com.zx.emanage.util.gen.entity.FolCreApprovalInfo;import com.zx.emanage.util.gen.entity.FolFileInfo;import com.zx.emanage.util.gen.entity.FolFinaBill;import com.zx.emanage.util.gen.entity.FolFinaBillBusinessTripDetail;import com.zx.emanage.util.gen.entity.FolFinaBillReimLoanRelation;import com.zx.emanage.util.gen.entity.FolFinaBillReimburseDetail;import com.zx.emanage.util.gen.entity.FolFinaBillSubsidiary;import com.zx.emanage.util.gen.entity.FolFinaLoanRelatedBill;import com.zx.platform.syscontext.vo.GridDataBean;/** * 类  名  称:FolFinaBillServiceImpl * 内容摘要:与fol_fina_bill表相关业务逻辑 * 作        者:wangyihan */@Service("folfinabillService")public class FolFinaBillServiceImpl implements IFolFinaBillService{    private static Logger log = LoggerFactory.getLogger(FolFinaBillServiceImpl.class);    @Autowired    private FolFinaBillDao folfinabillDao;    @Autowired    private FolFinaBillSubsidiaryDao folFinaBillSubsidiaryDao;    @Autowired    IUserService userService;    @Autowired    private HttpServletRequest request;    @Autowired    private FolFinaBillReimburseDetailDao folfinabillreimbursedetaildao;    @Autowired    private IFolApplyBillRelationService folApplyBillRelationServiceImpl;    @Autowired    private FolApplyBillRelationDao folApplyBillRelationDao;    @Autowired    private FolFinaLoanRelatedBillDao folFinaLoanRelatedBillDao;    @Autowired    private FolCreApprovalInfoDao folCreApprovalInfoDao;    @Autowired    private FolFinaBillBusinessTripDetailDao folfinabillbusinesstripdetaildao;    @Autowired    private PmPersonnelDao pmpersonneldao;    @Autowired    private FolFinaCollectionPayConfirmDao folFinaCollectionPayConfirmDao;    @Autowired    private FolFileInfoDao folFileInfoDao;    @Autowired    private SysDictMapper sysDictMapper;    @Autowired    private FolFinaBillReimLoanRelationDao folFinaBillReimLoanRelationDao;    @Autowired    private SendWechatEmailMsgService sendWechatEmailMsgService;    @Autowired    private FolFinaBillReimLoanRelationDao folfinabillreimloanrelationdao;	@Autowired	private DistrictDao districtDao;    /**     * @param FolFinaBillSearchBeanVO queryInfo     * @return     * @Title: getListWithoutPaging     * @Description: 查询列表(不带分页)     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    @Override    public Map<String, Object> getListWithoutPaging(FolFinaBillSearchBeanVO queryInfo)    {        Map<String, Object> paramMap = new HashMap<String, Object>();        paramMap.put("sortname", queryInfo.getSortname());        paramMap.put("sortorder", queryInfo.getSortorder());        List<Map<String, Object>> list = folfinabillDao.search(paramMap);        Map<String, Object> resMap = new HashMap<String, Object>();        resMap.put("Rows", list);        return resMap;    }    /**     * @param FolFinaBillSearchBeanVO queryInfo     * @return     * @Title: getListWithPaging     * @Description: 查询列表(带分页)     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    @Override    public Map<String, Object> getListWithPaging(FolFinaBillSearchBeanVO queryInfo)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            PmPersonnel personnel = userService.getPmPersonnel(request.getHeader(GlobalVal.XTOKEN));            Map<String, Object> paramMap = new HashMap<String, Object>();            // 判断            if (StringUtils.isNotBlank(queryInfo.getBill_code()))            {                paramMap.put("bill_code", queryInfo.getBill_code());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_user_name_or_shortcode()))            {                paramMap.put("apply_user_name_or_shortcode", queryInfo.getApply_user_name_or_shortcode());                paramMap.put("apply_user_name", queryInfo.getApply_user_name_or_shortcode());                paramMap.put("apply_user_shrotcode", queryInfo.getApply_user_name_or_shortcode());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_user_deptid()))            {                paramMap.put("apply_user_deptid", queryInfo.getApply_user_deptid());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getDept_level_coding()))            {                paramMap.put("dept_level_coding", queryInfo.getDept_level_coding());            }            // 判断            if (queryInfo.getBill_state() != null)            {                paramMap.put("bill_state", queryInfo.getBill_state());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_date()))            {                paramMap.put("apply_date", queryInfo.getApply_date());            }            // 判断            if (queryInfo.getCharge_off_state() != null)            {                paramMap.put("charge_off_state", queryInfo.getCharge_off_state());            }            // 循环            for (String role_num : personnel.getRoles())            {                // 判断超级用户                if (role_num.equals("folcjyh"))                {                    resMap.put("is_cjyh_flag", true);                }            }            paramMap.put("user_id", personnel.getPersonnel_id());            paramMap.put("page_name", "JKD");            paramMap.put("bill_type", "1");            paramMap.put("sortname", queryInfo.getSortname());            paramMap.put("sortorder", queryInfo.getSortorder());            paramMap.put("pagesize", queryInfo.getPagesize());            paramMap.put("offset", queryInfo.getOffset());            List<Map<String, Object>> list = folfinabillDao.search(paramMap);            GridDataBean<Map<String, Object>> bean =                    new GridDataBean<Map<String, Object>>(queryInfo.getPage(), folfinabillDao.findCount(paramMap),                                                          list);            resMap = bean.getGridData();        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * @param FolFinaBillSearchBeanVO queryInfo     * @return     * @Title: selectGoodsApplicationBillsList     * @Description: 查询物品申请单列表     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    public Map<String, Object> selectGoodsApplicationBillsList(FolFinaBillSearchBeanVO queryInfo)    {        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            // 从缓存中取登录人            PmPersonnel personnel = userService.getPmPersonnel(request.getHeader(GlobalVal.XTOKEN));            // 调取IOA接口            RestTemplate restTemplate = new RestTemplate();            MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();            // 接口编号            form.add("interface_num", "IOA_OUT_order");            // 系统编号            form.add("sys_num", "FOL");            form.add("related_bill_code", queryInfo.getBill_code());            form.add("apply_date_begin", queryInfo.getApply_date_begin());            form.add("apply_date_end", queryInfo.getApply_date_end());            form.add("personnel_id", personnel.getPersonnel_id().toString());            form.add("page", queryInfo.getPage() + "");            form.add("pagesize", queryInfo.getPagesize() + "");            // 调用IOA接口            @SuppressWarnings("unchecked")            Map<String, Object> map = restTemplate.postForObject(GlobalVal.getProperty("nozzleUrl"), form, Map.class);            resMap.putAll(map);        }        catch (Exception e)        {            e.printStackTrace();        }        return resMap;    }    /**     * @param FolFinaBillSearchBeanVO queryInfo     * @return     * @Title: selectGoodsApplicationBillsApproval     * @Description: 查询物品申请单审批流程     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    public Map<String, Object> selectGoodsApplicationBillsApproval(FolFinaBillSearchBeanVO queryInfo)    {        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            // 调取IOA接口            RestTemplate restTemplate = new RestTemplate();            MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();            // 接口编号            form.add("interface_num", "IOA_OUT_approveInfo");            // 系统编号            form.add("sys_num", "FOL");            form.add("related_bill_id", queryInfo.getRelated_bill_id().toString());            form.add("page", queryInfo.getPage() + "");            form.add("pagesize", queryInfo.getPagesize() + "");            // 调用IOA接口            @SuppressWarnings("unchecked")            Map<String, Object> map = restTemplate.postForObject(GlobalVal.getProperty("nozzleUrl"), form, Map.class);            resMap.putAll(map);        }        catch (Exception e)        {            e.printStackTrace();        }        return resMap;    }    /**     * @param FolFinaBillSearchBeanVO queryInfo     * @return     * @Title: searchMyBillList     * @Description: 查询我的单据     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    public Map<String, Object> searchMyBillList(FolFinaBillSearchBeanVO queryInfo)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            PmPersonnel personnel = userService.getPmPersonnel(request.getHeader(GlobalVal.XTOKEN));            Map<String, Object> paramMap = new HashMap<String, Object>();            // 判断            if (StringUtils.isNotBlank(queryInfo.getBill_code()))            {                paramMap.put("bill_code", queryInfo.getBill_code());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_user_name_or_shortcode()))            {                paramMap.put("apply_user_name_or_shortcode", queryInfo.getApply_user_name_or_shortcode());                paramMap.put("apply_user_name", queryInfo.getApply_user_name_or_shortcode());                paramMap.put("apply_user_shrotcode", queryInfo.getApply_user_name_or_shortcode());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_user_deptid()))            {                paramMap.put("apply_user_deptid", queryInfo.getApply_user_deptid());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getDept_level_coding()))            {                paramMap.put("dept_level_coding", queryInfo.getDept_level_coding());            }            // 判断            if (queryInfo.getBill_state() != null)            {                paramMap.put("bill_state", queryInfo.getBill_state());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_date()))            {                paramMap.put("apply_date", queryInfo.getApply_date());            }            paramMap.put("user_id", personnel.getPersonnel_id());            paramMap.put("page_name", "WDDJ");            paramMap.put("sortname", queryInfo.getSortname());            paramMap.put("sortorder", queryInfo.getSortorder());            paramMap.put("pagesize", queryInfo.getPagesize());            paramMap.put("offset", queryInfo.getOffset());            List<Map<String, Object>> list = folfinabillDao.search(paramMap);            GridDataBean<Map<String, Object>> bean =                    new GridDataBean<Map<String, Object>>(queryInfo.getPage(), folfinabillDao.findCount(paramMap),                                                          list);            resMap = bean.getGridData();        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * @param FolFinaBillSearchBeanVO queryInfo     * @return     * @Title: searchColAndPayList     * @Description: 查询收付款列表     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    public Map<String, Object> searchColAndPayList(FolFinaBillSearchBeanVO queryInfo)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            PmPersonnel personnel = userService.getPmPersonnel(request.getHeader(GlobalVal.XTOKEN));            Map<String, Object> paramMap = new HashMap<String, Object>();            // 判断            if (StringUtils.isNotBlank(queryInfo.getBill_code()))            {                paramMap.put("bill_code", queryInfo.getBill_code());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_user_name_or_shortcode()))            {                paramMap.put("apply_user_name_or_shortcode", queryInfo.getApply_user_name_or_shortcode());                paramMap.put("apply_user_name", queryInfo.getApply_user_name_or_shortcode());                paramMap.put("apply_user_shrotcode", queryInfo.getApply_user_name_or_shortcode());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_user_deptid()))            {                paramMap.put("apply_user_deptid", queryInfo.getApply_user_deptid());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getDept_level_coding()))            {                paramMap.put("dept_level_coding", queryInfo.getDept_level_coding());            }            // 判断            if (queryInfo.getBill_type() != null)            {                paramMap.put("bill_type", queryInfo.getBill_type());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_date()))            {                paramMap.put("apply_date", queryInfo.getApply_date());            }            // 判断            if (queryInfo.getReimburse_type() != null)            {                paramMap.put("reimburse_type", queryInfo.getReimburse_type());            }            // 判断            if (queryInfo.getCharge_off_type() != null)            {                paramMap.put("charge_off_type", queryInfo.getCharge_off_type());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getData_type()))            {                paramMap.put("data_type", queryInfo.getData_type());            }            else            {                paramMap.put("data_type", "2");            }            paramMap.put("user_id", personnel.getPersonnel_id());            paramMap.put("page_name", "SXK");            paramMap.put("sortname", queryInfo.getSortname());            paramMap.put("sortorder", queryInfo.getSortorder());            paramMap.put("pagesize", queryInfo.getPagesize());            paramMap.put("offset", queryInfo.getOffset());            List<Map<String, Object>> list = folfinabillDao.search(paramMap);            GridDataBean<Map<String, Object>> bean =                    new GridDataBean<Map<String, Object>>(queryInfo.getPage(), folfinabillDao.findCount(paramMap),                                                          list);            resMap = bean.getGridData();            // 循环            for (String role_num : personnel.getRoles())            {                // 判断收付款专员                if (role_num.equals("folsfkzy") || role_num.equals("folcjyh"))                {                    resMap.put("is_sfkzy_flag", true);                }            }        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * @param Integer fol_fina_bill_id     * @return     * @Title: getInfoByPK     * @Description: 根据主键查询     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    @Override    public Map<String, Object> getInfoByPK(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");            Map<String, Object> paramMap = new HashMap<String, Object>();                        String user_json_str = JSON.toJSONString(personnel);            Map<String, Object> user_map = JSON.parseObject(user_json_str, new TypeReference<Map<String, Object>>()            {            });            resMap.putAll(user_map);                        // 不为0则为编辑            if (queryInfo.getFol_fina_bill_id() != null && queryInfo.getFol_fina_bill_id() != 0)            {                paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());                paramMap.put("sortname", "fol_fina_bill_id");                paramMap.put("sortorder", "desc");                List<Map<String, Object>> list = this.folfinabillDao.search(paramMap);                Map<String, Object> tmpMap = list.get(0);                // 判断                if (tmpMap.get("loan_amount") != null && !tmpMap.get("loan_amount").toString().equals(""))                {                    tmpMap.put("loan_amount", new BigDecimal(tmpMap.get("loan_amount").toString()).stripTrailingZeros()                                                                                                  .toPlainString());                }                // 判断                if (tmpMap.get("charge_off_diff_amount") != null &&                    !tmpMap.get("charge_off_diff_amount").toString().equals(""))                {                    tmpMap.put("charge_off_diff_amount",                               new BigDecimal(tmpMap.get("charge_off_diff_amount").toString()).stripTrailingZeros()                                                                                              .toPlainString());                }                // 判断                if (tmpMap.get("total_amount") != null && !tmpMap.get("total_amount").toString().equals(""))                {                    tmpMap.put("total_amount",                               new BigDecimal(tmpMap.get("total_amount").toString()).stripTrailingZeros()                                                                                    .toPlainString());                }                // 判断                if (tmpMap.get("balance_amount") != null && !tmpMap.get("balance_amount").toString().equals(""))                {                    tmpMap.put("balance_amount",                               new BigDecimal(tmpMap.get("balance_amount").toString()).stripTrailingZeros()                                                                                      .toPlainString());                }                resMap.putAll(tmpMap);                // 单据类型                // 1借款                if (tmpMap.get("bill_type").toString().equals("1"))                {                    paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());                    paramMap.put("enable_flag", "1");                    paramMap.put("sortname", "fol_fina_loan_related_bill_id");                    paramMap.put("sortorder", "asc");                    List<Map<String, Object>> related_bill_list = this.folFinaLoanRelatedBillDao.search(paramMap);                    // 判断                    if (related_bill_list != null && related_bill_list.size() > 0)                    {                        resMap.put("related_bill_list", related_bill_list);                    }                    else                    {                        resMap.put("related_bill_list", new ArrayList<Map<String, Object>>());                    }                    paramMap.put("sortname", null);                    paramMap.put("sortorder", null);                    List<Map<String, Object>> sxkList = folFinaCollectionPayConfirmDao.search(paramMap);                    // 判断                    if (sxkList != null && sxkList.size() > 0)                    {                        resMap.putAll(sxkList.get(0));                        paramMap.put("enable_flag", "1");                        paramMap.put("fol_id", queryInfo.getFol_fina_bill_id());                        paramMap.put("fol_other_id", sxkList.get(0).get("fol_fina_collection_pay_confirm_id"));                        List<Map<String, Object>> fileList = folFileInfoDao.getConfirmFiles(paramMap);                        resMap.put("fileList", fileList);                    }                                        paramMap.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);                    paramMap.put("fol_id", queryInfo.getFol_fina_bill_id());                    List<Map<String, Object>> jkdFileList = folFileInfoDao.search(paramMap);                    // 判断                    if(jkdFileList != null)                    {                    	resMap.put("jkdFileList", jkdFileList);                    }                    else                    {                    	resMap.put("jkdFileList", new ArrayList<Map<String, Object>>());                    }                }                // 2费用报销                else if (tmpMap.get("bill_type").toString().equals("2"))                {                    paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());                    paramMap.put("fol_fina_bill_subsidiary_id", queryInfo.getFol_fina_bill_subsidiary_id());                    paramMap.put("sortname", "fol_fina_bill_reimburse_detail_id");                    paramMap.put("sortorder", "asc");                    List<Map<String, Object>> reimburseDetailList = folfinabillreimbursedetaildao.search(paramMap);                    resMap.put("reimburseDetailList", reimburseDetailList);                    BigDecimal fill_amount_sum = BigDecimal.ZERO;                    // 合计                    for (Map<String, Object> detailsMap : reimburseDetailList)                    {                        fill_amount_sum = fill_amount_sum.add(new BigDecimal(detailsMap.get("fill_amount").toString()));                    }                    resMap.put("fill_amount_sum", fill_amount_sum);                    // 查询关联的借款单信息                    List<Map<String, Object>> beseInfoList = folfinabillDao.getConfirmReimburseInfo(paramMap);                    int loan_num =0;                    // 格式化金额                    for (Map<String, Object> tmpMap1 : beseInfoList)                    {                    	//判断                    	if(tmpMap1.get("total_amount_reimburse")!=null)                     	{                    		 tmpMap1.put("total_amount_reimburse", decimalFormat                                     .format(new BigDecimal(tmpMap1.get("total_amount_reimburse").toString())));	                    	}                    	//loan_subsidiary_id                    	if(tmpMap1.containsKey("loan_subsidiary_id")&&tmpMap1.get("loan_subsidiary_id")!=null)                     	{                    		loan_num++;                    	}                    }                    // 判断					if (beseInfoList != null && beseInfoList.size() > 0 && loan_num > 0)                    {                        resMap.put("beseInfoList", beseInfoList);                    }                    else                    {                        resMap.put("beseInfoList", new ArrayList<>());                    }					Map<String, Object> fileParamMap = new HashMap<String, Object>();					fileParamMap.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);					fileParamMap.put("fol_id", queryInfo.getFol_fina_bill_id());					List<Map<String, Object>> jkdFileList = folFileInfoDao.search(fileParamMap);                    // 判断                    if(jkdFileList != null)                    {                    	resMap.put("jkdFileList", jkdFileList);                    }                    else                    {                    	resMap.put("jkdFileList", new ArrayList<Map<String, Object>>());                    }                }                // 3出差报销                else if (tmpMap.get("bill_type").toString().equals("3"))                {                    paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());                    paramMap.put("fol_fina_bill_subsidiary_id", queryInfo.getFol_fina_bill_subsidiary_id());                    paramMap.put("sortname", "fol_fina_bill_reimburse_detail_id");                    paramMap.put("sortorder", "asc");                    List<Map<String, Object>> reimburseDetailList = folfinabillreimbursedetaildao.search(paramMap);                    tmpMap.put("reimburseDetailList", reimburseDetailList);					Map<String, Object> fileParamMap = new HashMap<String, Object>();					fileParamMap.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);					fileParamMap.put("fol_id", queryInfo.getFol_fina_bill_id());					List<Map<String, Object>> jkdFileList = folFileInfoDao.search(fileParamMap);                    // 判断                    if(jkdFileList != null)                    {                    	resMap.put("jkdFileList", jkdFileList);                    }                    else                    {                    	resMap.put("jkdFileList", new ArrayList<Map<String, Object>>());                    }                }            }            else            {                resMap.put("bill_cause", "");                resMap.put("loan_amount", "");                resMap.put("charge_off_diff_amount", "");                resMap.put("loan_type", "");                resMap.put("related_bill_list", new ArrayList<Map<String, Object>>());                resMap.put("reimburseDetailList", new ArrayList<Map<String, Object>>());                resMap.put("fileList", new ArrayList<Map<String, Object>>());                resMap.put("card_default", "1");                resMap.put("jkdFileList", new ArrayList<Map<String, Object>>());            }            // 判断是否为借款单            if(StringUtils.isNotEmpty(queryInfo.getPage_name()))            {            	// 判断            	if(queryInfo.getPage_name().equals("JKD"))            	{            		// 判断                	if(resMap.get("card_default") == null || resMap.get("card_default").toString().equals("1"))                	{                		resMap.put("receivables_name", personnel.getPersonnel_name());                		resMap.put("receivables_bank", personnel.getPersonnel_bank_title());                		resMap.put("receivables_bank_branch", personnel.getPersonnel_bankName());                		resMap.put("receivables_bank_number", personnel.getPersonnel_bankCardCode());                		resMap.put("receivables_bank_pro", personnel.getBank_province());                		resMap.put("receivables_bank_city", personnel.getBank_city());                		resMap.put("bank_num", personnel.getBank_num());                	}                	                	resMap.put("default_receivables_name", personnel.getPersonnel_name());                	resMap.put("default_receivables_bank", personnel.getPersonnel_bank_title());                	resMap.put("default_receivables_bank_branch", personnel.getPersonnel_bankName());                	resMap.put("default_receivables_bank_number", personnel.getPersonnel_bankCardCode());                	resMap.put("default_receivables_bank_pro", personnel.getBank_province());                	resMap.put("default_receivables_bank_city", personnel.getBank_city());                	resMap.put("default_bank_num", personnel.getBank_num());                	resMap.put("default_receivables_bank_pro_str", personnel.getBank_province_str());                	resMap.put("default_receivables_bank_city_str", personnel.getBank_city_str());            	}            }                        Date date = new Date();            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");            resMap.put("now_date", format.format(date));        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * @param Integer fol_fina_bill_id     * @return     * @Title: getLoanBillInfo     * @Description: 查询借款单信息     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    public Map<String, Object> getLoanBillInfo(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            Map<String, Object> paramMap = new HashMap<String, Object>();            List<Map<String, Object>> related_bill_list = new ArrayList<Map<String, Object>>();            paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());            paramMap.put("sortname", "fol_fina_bill_id");            paramMap.put("sortorder", "desc");            List<Map<String, Object>> list = this.folfinabillDao.search(paramMap);            Map<String, Object> tmpMap = list.get(0);            // 判断            if (tmpMap.get("loan_amount") != null && !tmpMap.get("loan_amount").toString().equals(""))            {                tmpMap.put("loan_amount",                           new BigDecimal(tmpMap.get("loan_amount").toString()).stripTrailingZeros().toPlainString());            }            resMap.putAll(tmpMap);            paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());            paramMap.put("enable_flag", "1");            paramMap.put("sortname", "fol_fina_loan_related_bill_id");            paramMap.put("sortorder", "asc");            related_bill_list = this.folFinaLoanRelatedBillDao.search(paramMap);            resMap.put("related_bill_list", related_bill_list);            String user_json_str = JSON.toJSONString(personnel);            Map<String, Object> user_map = JSON.parseObject(user_json_str, new TypeReference<Map<String, Object>>()            {            });            resMap.putAll(user_map);            Date date = new Date();            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");            resMap.put("now_date", format.format(date));        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * @param FolFinaBill bean, UserBean user     * @return     * @Title: save     * @Description: 新增     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    @Override    @Transactional    public Map<String, Object> save(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            java.sql.Timestamp now_timestamp = new java.sql.Timestamp(System.currentTimeMillis());            String queryInfo_json = JSON.toJSONString(queryInfo);                        FolFinaBill bean1 = new FolFinaBill();            com.zx.emanage.util.gen.BeanUtils.copyProperties(bean1, queryInfo);            bean1.setBill_code(CodeNoUtil.getLoanCreCode());            bean1.setApply_date(new java.sql.Date(now_timestamp.getTime()));            bean1.setApply_user_id(personnel.getPersonnel_id());            bean1.setApply_user_name(personnel.getPersonnel_name());            bean1.setApply_user_shrotcode(personnel.getPersonnel_shortCode());            bean1.setApply_user_postname(personnel.getPersonnel_postName());            bean1.setApply_user_postid(personnel.getPersonnel_postId());            bean1.setApply_user_deptid(personnel.getPersonnel_deptId());            bean1.setApply_user_deptname(personnel.getPersonnel_deptName());            bean1.setApply_user_pdeptid(personnel.getDept_pid());            bean1.setApply_user_pdeptname(personnel.getDept_pname());            bean1.setBill_type(1);            // 审批当前级别            bean1.setCurrent_level(1);            // 是否可以撤销 1可以 0不可以            bean1.setIs_revoke(1);            bean1.setCreate_timestamp(now_timestamp);            bean1.setCreate_user_id(personnel.getPersonnel_id());            bean1.setCreate_user_name(personnel.getPersonnel_name());            bean1.setCreate_user_shortcode(personnel.getPersonnel_shortCode());            bean1.setLast_update_timestamp(now_timestamp);            bean1.setLast_update_user_id(personnel.getPersonnel_id());            bean1.setEnable_flag(1);            folfinabillDao.save(bean1);            FolFinaBillSubsidiary bean2 = JSON.parseObject(queryInfo_json, new TypeReference<FolFinaBillSubsidiary>()            {            });                        bean2.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                        // 判断是否为默认            if(queryInfo.getCard_default().equals("1"))            {            	bean2.setReceivables_bank(personnel.getPersonnel_bank_title());            	bean2.setReceivables_name(personnel.getPersonnel_name());            	bean2.setReceivables_bank_number(personnel.getPersonnel_bankCardCode());            	bean2.setReceivables_bank_branch(personnel.getPersonnel_bankName());            	bean2.setBank_num(personnel.getBank_num());            	bean2.setReceivables_bank_pro(personnel.getBank_province());            	bean2.setReceivables_bank_city(personnel.getBank_city());            }            else            {            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_pro()))            	{            		bean2.setReceivables_bank_pro(null);            	}            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_city()))            	{            		bean2.setReceivables_bank_city(null);            	}            }                        bean2.setTotal_amount(bean2.getLoan_amount());            bean2.setColl_pay_amount(bean2.getLoan_amount());            bean2.setEnable_flag(1);                        bean2.setReceivables_bank_number(bean2.getReceivables_bank_number()!=null?  bean2.getReceivables_bank_number().replace(" ", ""):"");            folFinaBillSubsidiaryDao.save(bean2);            // 判断空            if (StringUtils.isNotBlank(queryInfo.getRelated_bill_list_json()))            {                // 关联物品信息json                List<FolFinaLoanRelatedBill> related_bill_list =                        JSON.parseObject(queryInfo.getRelated_bill_list_json(),                                         new TypeReference<List<FolFinaLoanRelatedBill>>()                                         {                                         });                // 循环                for (FolFinaLoanRelatedBill bean : related_bill_list)                {                    bean.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                    bean.setFol_fina_bill_subsidiary_id(bean2.getFol_fina_bill_subsidiary_id());                    bean.setCreate_timestamp(now_timestamp);                    bean.setCreate_user_id(personnel.getPersonnel_id());                    bean.setCreate_user_name(personnel.getPersonnel_name());                    bean.setCreate_user_shortcode(personnel.getPersonnel_shortCode());                    bean.setLast_update_timestamp(now_timestamp);                    bean.setLast_update_user_id(personnel.getPersonnel_id());                    bean.setEnable_flag(1);                    this.folFinaLoanRelatedBillDao.save(bean);                    List<FolFileInfo> file_list = JSON                            .parseObject(bean.getImg_path(), new TypeReference<List<FolFileInfo>>()                            {                            });                    // 循环                    for (FolFileInfo bean_file : file_list)                    {                        bean_file.setAttachment_module(FOLMsgInfo.FILE_CODE_WPSQD);                        bean_file.setFol_id(bean.getFol_fina_bill_id());                        bean_file.setFol_other_id(bean.getFol_fina_loan_related_bill_id());                        bean_file.setEnable_flag(1);                        this.folFileInfoDao.save(bean_file);                    }                }            }                        // 判断            if(StringUtils.isNotEmpty(queryInfo.getFileJson()))            {            	List<FolFileInfo> file_list = JSON                        .parseObject(queryInfo.getFileJson(), new TypeReference<List<FolFileInfo>>()                        {                        });                // 循环                for (FolFileInfo bean_file : file_list)                {                    bean_file.setAttachment_module(FOLMsgInfo.FILE_CODE_DJSQ);                    bean_file.setData_type_name(FOLMsgInfo.FILE_CODE_DJSQ_T);                    bean_file.setData_detail_name(FOLMsgInfo.FILE_CODE_DJSQ_D);                    bean_file.setFol_id(bean1.getFol_fina_bill_id());                    bean_file.setFol_other_id(bean2.getFol_fina_bill_subsidiary_id());                    bean_file.setEnable_flag(1);					this.folFileInfoDao.save(bean_file);                }            }            /**             * @param id  申请人             * @param bill_id 单据id             * @param apply_type 审批类型             * @param var 条件参数             */            List<FolApplyBillRelation> folApplyList =             		JSON.parseObject(queryInfo.getFlow_info_json(), new TypeReference<List<FolApplyBillRelation>>()	                {	                });            // 判断不为空            if (folApplyList != null && folApplyList.size() > 0)            {            	// 循环            	for(FolApplyBillRelation relation : folApplyList)            	{            		relation.setFol_apply_bill_relation_id(null);            		relation.setFol_fina_bill_id(bean1.getFol_fina_bill_id());            		relation.setApproval_type("1");            		relation.setEnable_flag(1);            		relation.setIsPhone("0");        		    relation.setLevel_flag("1");        		    relation.setApproval_state(0);            	}            	            	FolApplyBillRelation relation = this.addApprovalInfoForCWSP(folApplyList, bean1.getFol_fina_bill_id());            	// 判断            	if(relation != null)            	{            		folApplyList.add(relation);            	}            	                folApplyBillRelationServiceImpl.saveBatch(folApplyList, personnel);            }                        // 调用流程(1草稿 2 审核中 3 待签收4 已完成 0已作废)            if (bean1.getBill_state().intValue() == 2)            {                FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();                // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据                approvalBean.setApproval_result("4");                // 审批意见                approvalBean.setApproval_advice("提交成功。");                // 流程节点code                approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_TJ);                // 流程节点名称                approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_TJ);                approvalBean.setFol_id(bean1.getFol_fina_bill_id());                // 流程生成                generateApprovalBean(approvalBean, personnel);                                try                {                    Map<String, Object> send_msg_param = new HashMap<>();                    send_msg_param.put("msg_code", "10001");                    send_msg_param.put("fol_fina_bill_id", bean1.getFol_fina_bill_id());                    send_msg_param.put("bill_code", bean1.getBill_code());                    send_msg_param.put("user_name_shortcode",                                       personnel.getPersonnel_name() + " " + personnel.getPersonnel_shortCode());                    send_msg_param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_DSP);                    // pc首页消息                    send_msg_param.put("pcmsg_code", "20003");                    send_msg_param.put("sys_code", "FOL");                    // 消息类型 1通知 2审批 3提醒                    send_msg_param.put("message_type", "2");                    send_msg_param.put("fol_id", bean1.getFol_fina_bill_id());                    sendWechatEmailMsgService.sendWechat(send_msg_param);                }                catch (Exception e)                {                    e.printStackTrace();                }            }        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();            // 回滚事物            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * @param FolFinaBill bean, UserBean user     * @return     * @Title: update     * @Description: 编辑     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    @Override    @Transactional    public Map<String, Object> update(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        Map<String, Object> paramMap = new HashMap<String, Object>();        try        {            java.sql.Timestamp now_timestamp = new java.sql.Timestamp(System.currentTimeMillis());            String queryInfo_json = JSON.toJSONString(queryInfo);            FolFinaBill bean1 = JSON.parseObject(queryInfo_json, new TypeReference<FolFinaBill>()            {            });            bean1.setLast_update_timestamp(now_timestamp);            bean1.setLast_update_user_id(personnel.getPersonnel_id());            folfinabillDao.update(bean1);            FolFinaBillSubsidiary bean2 = JSON.parseObject(queryInfo_json, new TypeReference<FolFinaBillSubsidiary>()            {            });            bean2.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                        // 判断是否为默认            if(queryInfo.getCard_default().equals("1"))            {            	bean2.setReceivables_bank(personnel.getPersonnel_bank_title());            	bean2.setReceivables_name(personnel.getPersonnel_name());            	bean2.setReceivables_bank_number(personnel.getPersonnel_bankCardCode());            	bean2.setReceivables_bank_branch(personnel.getPersonnel_bankName());            	bean2.setBank_num(personnel.getBank_num());            	bean2.setReceivables_bank_pro(personnel.getBank_province());            	bean2.setReceivables_bank_city(personnel.getBank_city());            }            else            {            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_pro()))            	{            		bean2.setReceivables_bank_pro(null);            	}            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_city()))            	{            		bean2.setReceivables_bank_city(null);            	}            }                        bean2.setTotal_amount(bean2.getLoan_amount());            bean2.setColl_pay_amount(bean2.getLoan_amount());                        bean2.setReceivables_bank_number(bean2.getReceivables_bank_number()!=null?  bean2.getReceivables_bank_number().replace(" ", ""):"");            folFinaBillSubsidiaryDao.update(bean2);            // 删除            if (queryInfo.getDelete_id_arr() != null && queryInfo.getDelete_id_arr().length > 0)            {                // 循环                for (String id : queryInfo.getDelete_id_arr())                {                    FolFinaLoanRelatedBill bean = new FolFinaLoanRelatedBill();                    bean.setFol_fina_loan_related_bill_id(Integer.parseInt(id));                    bean.setLast_update_timestamp(now_timestamp);                    bean.setLast_update_user_id(personnel.getPersonnel_id());                    bean.setEnable_flag(0);                    this.folFinaLoanRelatedBillDao.update(bean);                    paramMap.put("fol_other_id", bean.getFol_fina_loan_related_bill_id());                    this.folFileInfoDao.deleteFilesForWPSQD(paramMap);                }            }            // 判断空            if (StringUtils.isNotBlank(queryInfo.getRelated_bill_list_json()))            {                // 关联物品信息json                List<FolFinaLoanRelatedBill> related_bill_list =                        JSON.parseObject(queryInfo.getRelated_bill_list_json(),                                         new TypeReference<List<FolFinaLoanRelatedBill>>()                                         {                                         });                // 循环                for (FolFinaLoanRelatedBill bean : related_bill_list)                {                    bean.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                    bean.setFol_fina_bill_subsidiary_id(bean2.getFol_fina_bill_subsidiary_id());                    bean.setLast_update_timestamp(now_timestamp);                    bean.setLast_update_user_id(personnel.getPersonnel_id());                    bean.setEnable_flag(1);                    // 判断                    if (bean.getFol_fina_loan_related_bill_id() != null)                    {                        this.folFinaLoanRelatedBillDao.update(bean);                    }                    else                    {                        bean.setCreate_timestamp(now_timestamp);                        bean.setCreate_user_id(personnel.getPersonnel_id());                        bean.setCreate_user_name(personnel.getPersonnel_name());                        bean.setCreate_user_shortcode(personnel.getPersonnel_shortCode());                        this.folFinaLoanRelatedBillDao.save(bean);                        List<FolFileInfo> file_list = JSON                                .parseObject(bean.getImg_path(), new TypeReference<List<FolFileInfo>>()                                {                                });                        // 循环                        for (FolFileInfo bean_file : file_list)                        {                            bean_file.setAttachment_module(FOLMsgInfo.FILE_CODE_WPSQD);                            bean_file.setFol_id(bean.getFol_fina_bill_id());                            bean_file.setFol_other_id(bean.getFol_fina_loan_related_bill_id());                            bean_file.setEnable_flag(1);                            this.folFileInfoDao.save(bean_file);                        }                    }                }            }            // 删除附件            paramMap.put("fol_id", bean1.getFol_fina_bill_id());			paramMap.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);            this.folFileInfoDao.deleteFilesForDJSQ(paramMap);                        // 判断            if(StringUtils.isNotEmpty(queryInfo.getFileJson()))            {            	List<FolFileInfo> file_list = JSON                        .parseObject(queryInfo.getFileJson(), new TypeReference<List<FolFileInfo>>()                        {                        });                // 循环                for (FolFileInfo bean_file : file_list)                {                	bean_file.setFol_file_info_id(null);                    bean_file.setAttachment_module(FOLMsgInfo.FILE_CODE_DJSQ);                    bean_file.setData_type_name(FOLMsgInfo.FILE_CODE_DJSQ_T);                    bean_file.setData_detail_name(FOLMsgInfo.FILE_CODE_DJSQ_D);                    bean_file.setFol_id(bean1.getFol_fina_bill_id());                    bean_file.setFol_other_id(bean2.getFol_fina_bill_subsidiary_id());                    bean_file.setEnable_flag(1);                    this.folFileInfoDao.save(bean_file);                }            }                        // 删除审批节点            paramMap.put("fol_fina_bill_id", bean1.getFol_fina_bill_id());            this.folApplyBillRelationDao.deleteFolApplyBillRelationByBillId(paramMap);            	            /**             * @param id  申请人             * @param bill_id 单据id             * @param apply_type 审批类型             * @param var 条件参数             */            List<FolApplyBillRelation> folApplyList =         		JSON.parseObject(queryInfo.getFlow_info_json(), new TypeReference<List<FolApplyBillRelation>>()                {                });            // 判断不为空            if (folApplyList != null && folApplyList.size() > 0)            {            	// 循环            	for(FolApplyBillRelation relation : folApplyList)            	{            		relation.setFol_apply_bill_relation_id(null);            		relation.setFol_fina_bill_id(bean1.getFol_fina_bill_id());            		relation.setApproval_type("1");            		relation.setEnable_flag(1);            		relation.setIsPhone("0");        		    relation.setLevel_flag("1");        		    relation.setApproval_state(0);            	}            	            	FolApplyBillRelation relation = this.addApprovalInfoForCWSP(folApplyList, bean1.getFol_fina_bill_id());            	// 判断            	if(relation != null)            	{            		folApplyList.add(relation);            	}            	                folApplyBillRelationServiceImpl.saveBatch(folApplyList, personnel);            }                        // 调用流程(1草稿 2 审核中 3 待签收4 已完成 0已作废)            if (bean1.getBill_state().intValue() == 2)            {                FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();                // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据                approvalBean.setApproval_result("4");                // 审批意见                approvalBean.setApproval_advice("提交成功。");                // 流程节点code                approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_TJ);                // 流程节点名称                approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_TJ);                approvalBean.setFol_id(bean1.getFol_fina_bill_id());                // 流程生成                generateApprovalBean(approvalBean, personnel);                                try                {                    Map<String, Object> send_msg_param = new HashMap<>();                    send_msg_param.put("msg_code", "10001");                    send_msg_param.put("fol_fina_bill_id", bean1.getFol_fina_bill_id());                    send_msg_param.put("bill_code", bean1.getBill_code());                    send_msg_param.put("user_name_shortcode",                                       personnel.getPersonnel_name() + " " + personnel.getPersonnel_shortCode());                    send_msg_param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_DSP);                    // pc首页消息                    send_msg_param.put("pcmsg_code", "20003");                    send_msg_param.put("sys_code", "FOL");                    // 消息类型 1通知 2审批 3提醒                    send_msg_param.put("message_type", "2");                    send_msg_param.put("fol_id", bean1.getFol_fina_bill_id());                    sendWechatEmailMsgService.sendWechat(send_msg_param);                }                catch (Exception e)                {                    e.printStackTrace();                }            }        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();            // 回滚事物            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * @param FolFinaBill bean, UserBean user     * @return     * @Title: doAdd     * @Description: 补充     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    public Map<String, Object> doAdd(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            java.sql.Timestamp now_timestamp = new java.sql.Timestamp(System.currentTimeMillis());            FolFinaBill bean1 = this.folfinabillDao.get(queryInfo.getFol_fina_bill_id());            bean1.setLast_update_timestamp(now_timestamp);            bean1.setLast_update_user_id(personnel.getPersonnel_id());            folfinabillDao.update(bean1);            // 删除            if (queryInfo.getDelete_id_arr() != null && queryInfo.getDelete_id_arr().length > 0)            {                // 循环                for (String id : queryInfo.getDelete_id_arr())                {                    FolFinaLoanRelatedBill bean = new FolFinaLoanRelatedBill();                    bean.setFol_fina_loan_related_bill_id(Integer.parseInt(id));                    bean.setLast_update_timestamp(now_timestamp);                    bean.setLast_update_user_id(personnel.getPersonnel_id());                    bean.setEnable_flag(0);                    this.folFinaLoanRelatedBillDao.update(bean);                }            }            // 判断空            if (StringUtils.isNotBlank(queryInfo.getRelated_bill_list_json()))            {                // 关联物品信息json                List<FolFinaLoanRelatedBill> related_bill_list =                        JSON.parseObject(queryInfo.getRelated_bill_list_json(),                                         new TypeReference<List<FolFinaLoanRelatedBill>>()                                         {                                         });                // 循环                for (FolFinaLoanRelatedBill bean : related_bill_list)                {                    bean.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                    bean.setFol_fina_bill_subsidiary_id(queryInfo.getFol_fina_bill_subsidiary_id());                    bean.setLast_update_timestamp(now_timestamp);                    bean.setLast_update_user_id(personnel.getPersonnel_id());                    bean.setEnable_flag(1);                    // 判断                    if (bean.getFol_fina_loan_related_bill_id() != null)                    {                        this.folFinaLoanRelatedBillDao.update(bean);                    }                    else                    {                        bean.setCreate_timestamp(now_timestamp);                        bean.setCreate_user_id(personnel.getPersonnel_id());                        bean.setCreate_user_name(personnel.getPersonnel_name());                        bean.setCreate_user_shortcode(personnel.getPersonnel_shortCode());                        this.folFinaLoanRelatedBillDao.save(bean);                        List<FolFileInfo> file_list = JSON                                .parseObject(bean.getImg_path(), new TypeReference<List<FolFileInfo>>()                                {                                });                        // 循环                        for (FolFileInfo bean_file : file_list)                        {                            bean_file.setAttachment_module(FOLMsgInfo.FILE_CODE_WPSQD);                            bean_file.setFol_id(bean.getFol_fina_bill_id());                            bean_file.setFol_other_id(bean.getFol_fina_loan_related_bill_id());                            bean_file.setEnable_flag(1);                            this.folFileInfoDao.save(bean_file);                        }                    }                }            }            // 调用流程(1草稿 2 审核中 3 待签收4 已完成 0已作废)            FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();            // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据            approvalBean.setApproval_result("4");            // 审批意见            approvalBean.setApproval_advice("补充完成。");            // 流程节点code            approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_BC);            // 流程节点名称            approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_BC);            approvalBean.setFol_id(bean1.getFol_fina_bill_id());            // 流程生成            generateApprovalBean(approvalBean, personnel);        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * @param FolFinaBill bean, UserBean user     * @return     * @Title: loanApplicationBillValid     * @Description: 贷款报销单作废     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    public Map<String, Object> loanApplicationBillValid(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            java.sql.Timestamp now_timestamp = new java.sql.Timestamp(System.currentTimeMillis());            FolFinaBill bean = new FolFinaBill();            bean.setFol_fina_bill_id(queryInfo.getFol_fina_bill_id());            bean.setLast_update_timestamp(now_timestamp);            bean.setLast_update_user_id(personnel.getPersonnel_id());            // 已作废            bean.setBill_state(0);            folfinabillDao.update(bean);            // 调用流程(1草稿 2 审核中 3 待签收4 已完成 0已作废)            FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();            // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据            approvalBean.setApproval_result("2");            // 审批意见            approvalBean.setApproval_advice("单据作废。");            // 流程节点code            approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_ZF);            // 流程节点名称            approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_ZF);            approvalBean.setFol_id(bean.getFol_fina_bill_id());            // 流程生成            generateApprovalBean(approvalBean, personnel);        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * @param FolFinaBill bean, UserBean user     * @return     * @Title: loanApplicationBillWithdraw     * @Description: 贷款报销单撤回     * @author: wangyihan     * @time: 2020年07月31日 上午09:41:49     * history:     * 1、2020年07月31日 上午09:41:49 wangyihan 创建方法     */    @Transactional    public Map<String, Object> loanApplicationBillWithdraw(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            java.sql.Timestamp now_timestamp = new java.sql.Timestamp(System.currentTimeMillis());            FolFinaBill bean = this.folfinabillDao.get(queryInfo.getFol_fina_bill_id());                        // 判断状态是否变更        	if(bean.getIs_revoke() != null && bean.getIs_revoke().toString().equals("0"))        	{        		ret_code = ResultHelper.RET_ERROR;        		        		return ResultHelper.getReturnData(resMap, ret_code, "单据状态已改变，请刷新页面确认！");        	}                        bean.setLast_update_timestamp(now_timestamp);            bean.setLast_update_user_id(personnel.getPersonnel_id());            // 草稿            bean.setBill_state(1);            int j = 0;            j = folfinabillDao.update(bean);            Map<String, Object> paramMap = new HashMap<>();            paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());            // 查询当前审批相关状态信息            Map<String, Object> applyInfoMap = folfinabillDao.getBillInfo(paramMap);            // 单据类型 1借款 2费用报销 3出差报销            // 报销方式 1报销2冲账            if ("2".equals(applyInfoMap.get("bill_type").toString()) && applyInfoMap.get("reimburse_type") != null                && "2".equals(applyInfoMap.get("reimburse_type").toString()))            {                //不为空                if (applyInfoMap.get("fol_fina_bill_subsidiary_id_loans") != null)                {                    // 循环                    for (String id_loan : applyInfoMap.get("fol_fina_bill_subsidiary_id_loans").toString().split(","))                    {                        // 更新关联借款单的余额字段                        Map<String, Object> pMap = new HashMap<>();                        pMap.put("fol_fina_bill_subsidiary_id", id_loan);                        folFinaBillSubsidiaryDao.updateSubsidiaryBalanceAmount(pMap);                    }                }            }            FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();            // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据            approvalBean.setApproval_result("0");            // 审批意见            approvalBean.setApproval_advice("单据撤回。");            // 流程节点code            approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_CH);            // 流程节点名称            approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_CH);            approvalBean.setFol_id(bean.getFol_fina_bill_id());            // 流程生成            generateApprovalBean(approvalBean, personnel);            // 判断            if (j > 0)            {                try                {                    FolFinaBill ffb = folfinabillDao.get(bean.getFol_fina_bill_id());                    Map<String, Object> param = new HashMap<>();                    param.put("msg_code", "10006");                    param.put("fol_fina_bill_id", bean.getFol_fina_bill_id());                    param.put("bill_code", ffb.getBill_code());                    param.put("user_name_shortcode", ffb.getApply_user_name() + " " + ffb.getApply_user_shrotcode());                    param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_TZXX);                    // pc首页消息                    param.put("pcmsg_code", "20007");                    param.put("sys_code", "FOL");                    // 消息类型 1通知 2审批 3提醒                    param.put("message_type", "1");                    param.put("fol_id", bean.getFol_fina_bill_id());                    sendWechatEmailMsgService.sendWechat(param);                }                catch (Exception e)                {                    e.printStackTrace();                }            }        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();            // 回滚事物            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * 方法名称: getFolFinaBillReimburseList     * 内容摘要: TODO(报销单列表)     *     * @param queryInfo     * @return     * @author: wuguoqiang     * @time:2020年7月31日 下午3:58:05     */    @Override    public Map<String, Object> getFolFinaBillReimburseList(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        Map<String, Object> retMap = new HashMap<String, Object>();        Map<String, Object> paramMap = new HashMap<String, Object>();        paramMap.put("apply_user_id", personnel.getPersonnel_id());        // 判断        if (StringUtils.isNotBlank(queryInfo.getBill_code()))        {            paramMap.put("bill_code", queryInfo.getBill_code());        }        // 判断        if (StringUtils.isNotBlank(queryInfo.getApply_user_name_or_shortcode()))        {            paramMap.put("apply_user_name_or_shortcode", queryInfo.getApply_user_name_or_shortcode());            paramMap.put("apply_user_name", queryInfo.getApply_user_name_or_shortcode());            paramMap.put("apply_user_shrotcode", queryInfo.getApply_user_name_or_shortcode());        }        // 判断        if (StringUtils.isNotBlank(queryInfo.getApply_user_deptid()))        {            paramMap.put("apply_user_deptid", queryInfo.getApply_user_deptid());        }        // 判断        if (StringUtils.isNotBlank(queryInfo.getDept_level_coding()))        {            String dept_codings[] = queryInfo.getDept_level_coding().split(",");            List<String> dept_codingList = CollectionUtils.arrayToList(dept_codings);            paramMap.put("dept_codingList", dept_codingList);            // 用部门编码控制数据范围            paramMap.remove("apply_user_id");        }        // 判断        if (queryInfo.getBill_state_arr() != null && queryInfo.getBill_state_arr().length > 0)        {            StringBuffer sb = new StringBuffer("(");            // 循环            for (String s : queryInfo.getBill_state_arr())            {                sb.append(s + ",");            }            sb = new StringBuffer(sb.toString().substring(0, sb.toString().length() - 1));            sb.append(")");            paramMap.put("bill_state_arr", sb.toString());        }        // 判断        if (StringUtils.isNotBlank(queryInfo.getApply_date()))        {            paramMap.put("apply_date", queryInfo.getApply_date());        }        // 判断        if (queryInfo.getReimburse_type_arr() != null && queryInfo.getReimburse_type_arr().length > 0)        {            StringBuffer sb = new StringBuffer("(");            // 循环            for (String s : queryInfo.getReimburse_type_arr())            {                sb.append(s + ",");            }            sb = new StringBuffer(sb.toString().substring(0, sb.toString().length() - 1));            sb.append(")");            paramMap.put("reimburse_type_arr", sb.toString());        }        paramMap.put("sortname", queryInfo.getSortname());        paramMap.put("sortorder", queryInfo.getSortorder());        paramMap.put("pagesize", queryInfo.getPagesize());        paramMap.put("offset", queryInfo.getOffset());        List<Map<String, Object>> list = folfinabillDao.getFolFinaBillReimburseList(paramMap);        int total = folfinabillDao.getFolFinaBillReimburseListCount(paramMap);        retMap.put("list", list);        retMap.put("total", total);        return ResultHelper.getSuccessReturnData(retMap);    }    /**     * 方法名称: searchTodoList     * <p>     * 内容摘要:待办事项查询列表(带分页)     *     * @param map     * @return     * @author: Baisong     * @time:2020年7月31日 下午2:03:05     */    @Override    public Map<String, Object> searchTodoList(FolFinaBillSearchBeanVO queryInfo)    {        // 从缓存中取登录人        PmPersonnel personnel = userService.getPmPersonnel(request.getHeader(GlobalVal.XTOKEN));        Map<String, Object> paramMap = new HashMap<>();        paramMap.put("personnel_id", personnel.getPersonnel_id());        // 判断        if (StringUtils.isNotBlank(queryInfo.getBill_code()))        {            paramMap.put("bill_code", queryInfo.getBill_code());        }        // 判断        if (StringUtils.isNotBlank(queryInfo.getApply_user_name_or_shortcode()))        {            paramMap.put("apply_user_name", queryInfo.getApply_user_name_or_shortcode());            paramMap.put("apply_user_shrotcode", queryInfo.getApply_user_name_or_shortcode());        }        // 判断        if (StringUtils.isNotBlank(queryInfo.getApply_user_deptid()))        {            paramMap.put("apply_user_deptid", queryInfo.getApply_user_deptid());        }        // 判断        if (StringUtils.isNotBlank(queryInfo.getApply_date()))        {            paramMap.put("apply_date", queryInfo.getApply_date());        }        // 判断        if (queryInfo.getBill_type() != null)        {            paramMap.put("bill_type", queryInfo.getBill_type());        }        //判断        if (queryInfo.getSortname() == null || "".equals(queryInfo.getSortname()))        {            queryInfo.setSortname("fol_fina_bill_id");        }        paramMap.put("sortname", queryInfo.getSortname());        paramMap.put("sortorder", queryInfo.getSortorder());        paramMap.put("pagesize", queryInfo.getPagesize());        paramMap.put("offset", queryInfo.getOffset());        List<Map<String, Object>> list = folfinabillDao.searchTodoList(paramMap);        GridDataBean<Map<String, Object>> bean = new GridDataBean<Map<String, Object>>(queryInfo.getPage(),                                                                                       folfinabillDao                                                                                               .findTodoCount(paramMap),                                                                                       list);        return bean.getGridData();    }    /**     * 方法名称: getDeptSInfo     * <p>     * 内容摘要: 获取部门信息     *     * @return     * @author: Baisong     * @time:2020年8月3日 下午4:10:21     */    @Override    public Map<String, Object> getDeptSInfo()    {        Map<String, Object> retMap = new HashMap<>();        List<Map<String, Object>> deptList = folfinabillDao.getDeptSInfo(retMap);        retMap.put("deptList", deptList);        return retMap;    }    /**     * 方法名称: getFolFinaBillReimburseById     * 内容摘要: TODO(费用报销单模态框)     *     * @param queryInfo     * @param personnel     * @return     * @author: wuguoqiang     * @time:2020年8月5日 下午4:50:49     */    @Override    public Map<String, Object> getFolFinaBillReimburseById(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        Map<String, Object> resMap = new HashMap<String, Object>();        Map<String, Object> paramMap = new HashMap<String, Object>();        Map<String, Object> tmpMap = new HashMap<String, Object>();        // 不为0则为编辑        if (queryInfo.getFol_fina_bill_id() != null && queryInfo.getFol_fina_bill_id() != 0)        {            paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());            paramMap.put("fol_fina_bill_subsidiary_id", queryInfo.getFol_fina_bill_subsidiary_id());            paramMap.put("sortname", "fol_fina_bill_reimburse_detail_id");            paramMap.put("sortorder", "asc");            List<Map<String, Object>> list = folfinabillreimbursedetaildao.search(paramMap);            tmpMap.put("reimburseDetailList", list);            FolFinaBill ffb = folfinabillDao.get(queryInfo.getFol_fina_bill_id());            tmpMap.put("apply_date", ffb.getApply_date());            FolFinaBillSubsidiary ffbs = folFinaBillSubsidiaryDao.get(queryInfo.getFol_fina_bill_subsidiary_id());            /*Integer fol_fina_bill_subsidiary_id_relation = ffbs.getFol_fina_bill_subsidiary_id_relation();            //判断            if (fol_fina_bill_subsidiary_id_relation != null)            {                Map<String, Object> map = new HashMap<String, Object>();                paramMap.put("fol_fina_bill_subsidiary_id_relation", fol_fina_bill_subsidiary_id_relation);                map = folfinabillDao.getLoanApplicationBill(paramMap);                tmpMap.put("fol_fina_bill_subsidiary_id_relation", fol_fina_bill_subsidiary_id_relation);                tmpMap.put("relationLoanBillInfo", map);            }*/            tmpMap.put("total_amount", ffbs.getTotal_amount());            tmpMap.put("charge_off_type", ffbs.getCharge_off_type());            tmpMap.put("reimburse_type", ffbs.getReimburse_type());            tmpMap.put("charge_off_diff_amount", ffbs.getCharge_off_diff_amount());            Map<String, Object> param = new HashMap<String, Object>();            param.put("fol_fina_bill_subsidiary_id_reim", queryInfo.getFol_fina_bill_subsidiary_id());            List<Map<String, Object>> loan_list = folfinabillreimloanrelationdao.getRelationLoanBillList(param);            tmpMap.put("relationLoanBillList", loan_list);            tmpMap.put("receivables_name", ffbs.getReceivables_name());            tmpMap.put("receivables_bank", ffbs.getReceivables_bank());            tmpMap.put("receivables_bank_branch", ffbs.getReceivables_bank_branch());            tmpMap.put("receivables_bank_number", ffbs.getReceivables_bank_number());            tmpMap.put("receivables_bank_pro", ffbs.getReceivables_bank_pro());            tmpMap.put("receivables_bank_city", ffbs.getReceivables_bank_city());            tmpMap.put("bank_num", ffbs.getBank_num());            tmpMap.put("receivables_bank_pro_str", ffbs.getReceivables_bank_pro_str());            tmpMap.put("receivables_bank_city_str", ffbs.getReceivables_bank_city_str());            tmpMap.put("suffix_pro", ffbs.getSuffix_pro());            tmpMap.put("suffix_city", ffbs.getSuffix_city());                        resMap.put("card_default", ffbs.getCard_default().toString());        }        else        {            Map<String, Object> map = new HashMap<String, Object>();            map.put("reasons_cost", "");            map.put("number_sheets", "");            map.put("fill_amount", "");            List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();            list.add(map);            tmpMap.put("reimburseDetailList", list);            resMap.put("card_default", "1");        }		Map<String, Object> paramMapFile = new HashMap<String, Object>();		paramMapFile.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);		paramMapFile.put("fol_id", queryInfo.getFol_fina_bill_id());		List<Map<String, Object>> jkdFileList = folFileInfoDao.search(paramMapFile);        // 判断        if(jkdFileList != null)        {        	resMap.put("jkdFileList", jkdFileList);        }        else        {        	resMap.put("jkdFileList", new ArrayList<Map<String, Object>>());        }        // 判断        if(resMap.get("card_default") == null || resMap.get("card_default").toString().equals("1"))        {        	tmpMap.put("receivables_name", personnel.getPersonnel_name());        	tmpMap.put("receivables_bank", personnel.getPersonnel_bank_title());        	tmpMap.put("receivables_bank_branch", personnel.getPersonnel_bankName());        	tmpMap.put("receivables_bank_number", personnel.getPersonnel_bankCardCode());        	tmpMap.put("receivables_bank_pro", personnel.getBank_province());        	tmpMap.put("receivables_bank_city", personnel.getBank_city());        	tmpMap.put("bank_num", personnel.getBank_num());        	tmpMap.put("receivables_bank_pro_str", personnel.getBank_province_str());        	tmpMap.put("receivables_bank_city_str", personnel.getBank_city_str());        	tmpMap.put("suffix_pro", personnel.getSuffix_pro());        	tmpMap.put("suffix_city", personnel.getSuffix_city());        }                tmpMap.put("default_receivables_name", personnel.getPersonnel_name());    	tmpMap.put("default_receivables_bank", personnel.getPersonnel_bank_title());    	tmpMap.put("default_receivables_bank_branch", personnel.getPersonnel_bankName());    	tmpMap.put("default_receivables_bank_number", personnel.getPersonnel_bankCardCode());    	tmpMap.put("default_receivables_bank_pro", personnel.getBank_province());    	tmpMap.put("default_receivables_bank_city", personnel.getBank_city());    	tmpMap.put("default_bank_num", personnel.getBank_num());    	tmpMap.put("default_receivables_bank_pro_str", personnel.getBank_province_str());    	tmpMap.put("default_receivables_bank_city_str", personnel.getBank_city_str());        resMap.put("user", personnel);        resMap.put("bean", tmpMap);                Date date = new Date();        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");        resMap.put("now_date", format.format(date));        return resMap;    }    /**     * 方法名称: addFolFinaBillReimburse     * 内容摘要: TODO(新增报销)     *     * @param queryInfo     * @param personnel     * @return     * @author: wuguoqiang     * @time:2020年8月6日 下午2:12:53     */    @Override    @Transactional    public Map<String, Object> addFolFinaBillReimburse(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            java.sql.Timestamp now_timestamp = new java.sql.Timestamp(System.currentTimeMillis());            String queryInfo_json = JSON.toJSONString(queryInfo);            FolFinaBill bean1 = new FolFinaBill();            com.zx.emanage.util.gen.BeanUtils.copyProperties(bean1, queryInfo);            bean1.setBill_code(CodeNoUtil.getReimburseCode());            bean1.setApply_date(new java.sql.Date(now_timestamp.getTime()));            bean1.setApply_user_id(personnel.getPersonnel_id());            bean1.setApply_user_name(personnel.getPersonnel_name());            bean1.setApply_user_shrotcode(personnel.getPersonnel_shortCode());            bean1.setApply_user_postname(personnel.getPersonnel_postName());            bean1.setApply_user_postid(personnel.getPersonnel_postId());            bean1.setApply_user_deptid(personnel.getPersonnel_deptId());            bean1.setApply_user_deptname(personnel.getPersonnel_deptName());            bean1.setApply_user_pdeptid(personnel.getDept_pid());            bean1.setApply_user_pdeptname(personnel.getDept_pname());            bean1.setBill_type(queryInfo.getBill_type());            // 审批当前级别            bean1.setCurrent_level(1);            // 是否可以撤销 1可以 0不可以            bean1.setIs_revoke(1);            bean1.setCreate_timestamp(now_timestamp);            bean1.setCreate_user_id(personnel.getPersonnel_id());            bean1.setCreate_user_name(personnel.getPersonnel_name());            bean1.setCreate_user_shortcode(personnel.getPersonnel_shortCode());            bean1.setLast_update_timestamp(now_timestamp);            bean1.setLast_update_user_id(personnel.getPersonnel_id());            bean1.setEnable_flag(1);            folfinabillDao.save(bean1);            // json转list            String list_str = queryInfo.getReimburseDetailList();            JSONArray arrayList = JSONArray.parseArray(list_str);            List<FolFinaBillReimburseDetail> reimburseDetailList = JSONObject.parseArray(arrayList.toJSONString(),                                                                                         FolFinaBillReimburseDetail.class);            FolFinaBillSubsidiary bean2 = JSON.parseObject(queryInfo_json, new TypeReference<FolFinaBillSubsidiary>()            {            });            bean2.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                        // 判断是否为默认            if(queryInfo.getCard_default().equals("1"))            {            	bean2.setReceivables_bank(personnel.getPersonnel_bank_title());            	bean2.setReceivables_name(personnel.getPersonnel_name());            	bean2.setReceivables_bank_number(personnel.getPersonnel_bankCardCode());            	bean2.setReceivables_bank_branch(personnel.getPersonnel_bankName());            	bean2.setBank_num(personnel.getBank_num());            	bean2.setReceivables_bank_pro(personnel.getBank_province());            	bean2.setReceivables_bank_city(personnel.getBank_city());            }            else            {            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_pro()))            	{            		bean2.setReceivables_bank_pro(null);            	}            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_city()))            	{            		bean2.setReceivables_bank_city(null);            	}            }                    	bean2.setReceivables_bank_number(bean2.getReceivables_bank_number()!=null?bean2.getReceivables_bank_number().replace(" ",""):"");            bean2.setEnable_flag(1);            /*// 如果多条费用报销，详情表只保存一条            if (reimburseDetailList.size() > 1)            {                bean2.setBill_cause(reimburseDetailList.get(0).getReasons_cost() + "等");            }            else            {                bean2.setBill_cause(reimburseDetailList.get(0).getReasons_cost());            }             */            folFinaBillSubsidiaryDao.save(bean2);			Map<String, Object> paramMap = new HashMap<String, Object>();			paramMap.put("fol_fina_bill_subsidiary_id", bean2.getFol_fina_bill_subsidiary_id());			// 处理收付款金额			handleCollPayAmount(paramMap);            // 循环插入            for (FolFinaBillReimburseDetail bean3 : reimburseDetailList)            {                bean3.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                bean3.setFol_fina_bill_subsidiary_id(bean2.getFol_fina_bill_subsidiary_id());                bean3.setCreate_timestamp(now_timestamp);                bean3.setCreate_user_id(personnel.getPersonnel_id());                bean3.setCreate_user_name(personnel.getPersonnel_name());                bean3.setCreate_user_shortcode(personnel.getPersonnel_shortCode());                bean3.setLast_update_timestamp(now_timestamp);                bean3.setLast_update_user_id(personnel.getPersonnel_id());                bean3.setEnable_flag(1);            }            folfinabillreimbursedetaildao.batchSave(reimburseDetailList);            //选择冲账时			if (queryInfo.getReimburse_type() != null && queryInfo.getReimburse_type() == 2)            {                // json转list                String loan_list_str = queryInfo.getRelationLoanBillList();                JSONArray loanArrayList = JSONArray.parseArray(loan_list_str);                List<FolFinaBillReimLoanRelation> relationLoanBillList = JSONObject                        .parseArray(loanArrayList.toJSONString(),                                    FolFinaBillReimLoanRelation.class);                // 循环插入                for (FolFinaBillReimLoanRelation bean4 : relationLoanBillList)                {                    bean4.setFol_fina_bill_subsidiary_id_reim(bean2.getFol_fina_bill_subsidiary_id());                    bean4.setEnable_flag(1);                }                folfinabillreimloanrelationdao.batchSave(relationLoanBillList);            }            // 判断            if(StringUtils.isNotEmpty(queryInfo.getFileJson()))            {            	List<FolFileInfo> file_list = JSON                        .parseObject(queryInfo.getFileJson(), new TypeReference<List<FolFileInfo>>()                        {                        });                // 循环                for (FolFileInfo bean_file : file_list)                {					bean_file.setFol_file_info_id(null);                    bean_file.setAttachment_module(FOLMsgInfo.FILE_CODE_DJSQ);                    bean_file.setData_type_name(FOLMsgInfo.FILE_CODE_DJSQ_T);                    bean_file.setData_detail_name(FOLMsgInfo.FILE_CODE_DJSQ_D);                    bean_file.setFol_id(bean1.getFol_fina_bill_id());                    bean_file.setFol_other_id(bean2.getFol_fina_bill_subsidiary_id());                    bean_file.setEnable_flag(1);                }                //判断                if(file_list!=null&&file_list.size()>0)                {    				this.folFileInfoDao.saveBatch(file_list);                }            }                        /**             * @param id  申请人             * @param bill_id 单据id             * @param apply_type 审批类型             * @param var 条件参数             */            List<FolApplyBillRelation> folApplyList =         		JSON.parseObject(queryInfo.getFlow_info_json(), new TypeReference<List<FolApplyBillRelation>>()                {                });            // 判断不为空            if (folApplyList != null && folApplyList.size() > 0)            {            	// 循环            	for(FolApplyBillRelation relation : folApplyList)            	{            		relation.setFol_apply_bill_relation_id(null);            		relation.setFol_fina_bill_id(bean1.getFol_fina_bill_id());            		relation.setApproval_type("1");            		relation.setEnable_flag(1);            		relation.setIsPhone("0");        		    relation.setLevel_flag("1");        		    relation.setApproval_state(0);            	}            	            	FolApplyBillRelation relation = this.addApprovalInfoForCWSP(folApplyList, bean1.getFol_fina_bill_id());            	// 判断            	if(relation != null)            	{            		folApplyList.add(relation);            	}            	                folApplyBillRelationServiceImpl.saveBatch(folApplyList, personnel);            }                        // 调用流程(1草稿 2 审核中 3 待签收4 已完成 0已作废)            if (bean1.getBill_state().intValue() == 2)            {                // 单据类型 1借款 2费用报销 3出差报销                // 报销方式 1报销2冲账                if (bean2.getReimburse_type() != null && bean2.getReimburse_type() == 2                    && bean2.getFol_fina_bill_subsidiary_id() != null)                {                    // 更新关联借款单的余额字段                    Map<String, Object> pMap = new HashMap<>();                    pMap.put("fol_fina_bill_subsidiary_id_reim", bean2.getFol_fina_bill_subsidiary_id());                    List<Map<String, Object>> listMap = folFinaBillReimLoanRelationDao.getReimLoanRelationInfo(pMap);                    //是否为空                    if (listMap != null && listMap.size() > 0)                    {                        // 循环                        for (Map<String, Object> map : listMap)                        {                            pMap.put("fol_fina_bill_subsidiary_id", map.get("fol_fina_bill_subsidiary_id_loan"));                            folFinaBillSubsidiaryDao.updateSubsidiaryBalanceAmount(pMap);                        }                    }                }                FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();                // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据                approvalBean.setApproval_result("4");                // 审批意见                approvalBean.setApproval_advice("提交成功。");                // 流程节点code                approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_TJ);                // 流程节点名称                approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_TJ);                approvalBean.setFol_id(bean1.getFol_fina_bill_id());                // 流程生成                generateApprovalBean(approvalBean, personnel);                try                {                    // 发送微信消息                    Map<String, Object> param = new HashMap<>();                    param.put("msg_code", "10001");                    param.put("fol_fina_bill_id", bean1.getFol_fina_bill_id());                    param.put("bill_code", bean1.getBill_code());                    param.put("user_name_shortcode",                              bean1.getApply_user_name() + " " + bean1.getApply_user_shrotcode());                    param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_DSP);                    // pc首页消息                    param.put("pcmsg_code", "20003");                    param.put("sys_code", "FOL");                    // 消息类型 1通知 2审批 3提醒                    param.put("message_type", "2");                    param.put("fol_id", bean1.getFol_fina_bill_id());                    sendWechatEmailMsgService.sendWechat(param);                }                catch (Exception e)                {                    e.printStackTrace();                }            }        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();            // 回滚事务            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * 方法名称: getLoanInfo     * <p>     * 内容摘要: 获取审批单详情     *     * @param queryInfo     * @return     * @author: Baisong     * @time:2020年8月5日 下午4:42:11     */    @Override    public Map<String, Object> getLoanInfo(FolFinaBillSearchBeanVO queryInfo)    {        Map<String, Object> retMap = new HashMap<>();        Map<String, Object> paramMap = new HashMap<>();        List<Map<String, Object>> loanList = new ArrayList<>();        //判断是否为空        if (queryInfo.getFol_apply_bill_relation_id() != null)        {            retMap.put("fol_apply_bill_relation_id", queryInfo.getFol_apply_bill_relation_id());            loanList = folfinabillDao.getLoanInfo(retMap);        }        else if (queryInfo.getFol_fina_bill_id() != null)        {            retMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());            loanList = folfinabillDao.getConfirmLoanInfo(retMap);        }                paramMap.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);        paramMap.put("fol_id", queryInfo.getFol_fina_bill_id());        List<Map<String, Object>> jkdFileList = folFileInfoDao.search(paramMap);        // 判断        if(jkdFileList != null)        {        	retMap.put("jkdFileList", jkdFileList);        }        else        {        	retMap.put("jkdFileList", new ArrayList<Map<String, Object>>());        }                // 判断        if (loanList != null && loanList.size() > 0)        {            retMap.put("beseInfo", loanList.get(0));        }        else        {            retMap.put("beseInfo", new HashMap<>());        }        retMap.put("confirm_date", new java.sql.Date(System.currentTimeMillis()));        return retMap;    }	/**	 * 方法名称: saveBatchApplyInfo 内容摘要: TODO(这里详细描述这个方法的作用)	 * 	 * @param queryInfo	 * @return	 *	 * @author: Baisong	 * @time:2021年6月26日 下午2:17:48	 */	@Override	@Transactional	public Map<String, Object> saveBatchApplyInfo(FolFinaBillSearchBeanVO queryInfo)	{		// 从缓存中取登录人		PmPersonnel personnel = new PmPersonnel();		// 判断 是否是移动端 1移动端 0pc		if (queryInfo != null && queryInfo.getIs_mobile() != null && "1".equals(queryInfo.getIs_mobile().toString())) 		{			// 查询员工信息			personnel = pmpersonneldao.findPersonnelById(queryInfo.getUser_id().toString());		}		else 		{			// 从缓存中取登录人			personnel = userService.getPmPersonnel(request.getHeader(GlobalVal.XTOKEN));		}		Map<String, Object> paramMap = new HashMap<>();		Map<String, Object> retMap = new HashMap<>();		// 判断是多条还是单条		if (StringUtils.isNotBlank(queryInfo.getFol_apply_bill_relation_ids()))		{			paramMap.put("fol_apply_bill_relation_ids", queryInfo.getFol_apply_bill_relation_ids());					// 查询当前审批相关状态信息			List<Map<String, Object>> applyInfoMapList = folfinabillDao.getBatchApplyInfo(paramMap);			//判断			for(Map<String, Object>  applyInfoMap:   applyInfoMapList)			{				queryInfo.setFol_apply_bill_relation_id(Integer.valueOf(applyInfoMap.get("fol_apply_bill_relation_id").toString()));				Map<String, Object> resultMap = saveApplyInfo(queryInfo, personnel, applyInfoMap);				// 判断结果				if (resultMap!=null&&resultMap.get("result")!=null&&"success".equals(resultMap.get("result").toString()))				{					retMap.putAll(resultMap);				}				else 				{					TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();					retMap.putAll(resultMap);				}			}			return retMap;		}		// 判断是多条还是单条		else if (queryInfo.getFol_apply_bill_relation_id() != null)		{			paramMap.put("fol_apply_bill_relation_id", queryInfo.getFol_apply_bill_relation_id());			// 查询当前审批相关状态信息			Map<String, Object> applyInfoMap = folfinabillDao.getApplyInfo(paramMap);			Map<String, Object> resultMap = saveApplyInfo(queryInfo, personnel, applyInfoMap);			retMap.putAll(resultMap);		}		return retMap;	}    /**     * 方法名称: saveApplyInfo     * <p>     * 内容摘要: 保存单据审批信息     *     * @param queryInfo     * @return     * @author: Baisong     * @time:2020年8月7日 下午2:21:50     */    @Override	public Map<String, Object> saveApplyInfo(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel,			Map<String, Object> applyInfoMap)    {    /*    // 从缓存中取登录人        PmPersonnel personnel = new PmPersonnel();        // 判断 是否是移动端 1移动端 0pc        if (queryInfo != null && queryInfo.getIs_mobile() != null && "1".equals(queryInfo.getIs_mobile().toString()))        {            // 查询员工信息            personnel = pmpersonneldao.findPersonnelById(queryInfo.getUser_id().toString());        }        else        {            // 从缓存中取登录人            personnel = userService.getPmPersonnel(request.getHeader(GlobalVal.XTOKEN));        }		Map<String, Object> paramMap = new HashMap<>();		paramMap.put("fol_apply_bill_relation_id", queryInfo.getFol_apply_bill_relation_id());		// 查询当前审批相关状态信息		Map<String, Object> applyInfoMap = folfinabillDao.getApplyInfo(paramMap);*/		Map<String, Object> retMap = new HashMap<>();        // 1拒件 2 上级审批 3待确认        int send_msg_flag = 0;        // 判断是否为空 并且是未审批过的        if (applyInfoMap != null && "0".equals(applyInfoMap.get("approval_state").toString()))        {            // 审批类            FolApplyBillRelation folApplyBillRelation = new FolApplyBillRelation();            folApplyBillRelation.setFol_apply_bill_relation_id(queryInfo.getFol_apply_bill_relation_id());            folApplyBillRelation.setApproval_advice(queryInfo.getApproval_advice());            folApplyBillRelation.setApproval_state(queryInfo.getApproval_state());            folApplyBillRelation.setApproval_timestamp(new Timestamp(System.currentTimeMillis()));            // 不是手机端操作            folApplyBillRelation                    .setIsPhone(queryInfo.getIs_mobile() == null ? "0" : queryInfo.getIs_mobile().toString());            folApplyBillRelation.setApproval_state(queryInfo.getApproval_state());            // 单据类            FolFinaBill folFinaBill = new FolFinaBill();            Integer fol_fina_bill_id = Integer.valueOf(applyInfoMap.get("fol_fina_bill_id").toString());            folFinaBill.setFol_fina_bill_id(fol_fina_bill_id);            folFinaBill.setLast_update_user_id(personnel.getPersonnel_id());            folFinaBill.setLast_update_timestamp(new Timestamp(System.currentTimeMillis()));            // 是否可以撤销 1可以 0不可以            folFinaBill.setIs_revoke(0);            // 直接更新审批人对应的单据状态和意见等 1同意 2驳回            if (folApplyBillRelation.getApproval_state().intValue() == 2)            {                // 存在拒件则拒绝                folFinaBill.setBill_state(0);                // 1拒件 2 上级审批 3待确认                send_msg_flag = 1;            }            else            {                // 如果审批级别为0则此单据审批完成                if ("0".equals(applyInfoMap.get("level_index").toString()))                {                    // 1草稿 2 审核中 3 待确认4 已完成 0已作废                    folFinaBill.setBill_state(3);                }                // 获取同级审批状态 如果存在还未审批完成的则不能增加审批级别                if (applyInfoMap.get("tj_num") != null && Integer.valueOf(applyInfoMap.get("tj_num").toString()) > 0)                {                    // 1拒件 2 上级审批 3待确认 4同级还未审批完成                    send_msg_flag = 4;                }                else                {                    // 获取上级审批信息                    if (applyInfoMap.get("sj_num") != null                        && Integer.valueOf(applyInfoMap.get("sj_num").toString()) > 0)                    {                        folFinaBill.setCurrent_level(Integer.valueOf(applyInfoMap.get("level_index").toString()) + 1);                        // 1拒件 2 上级审批 3待确认                        send_msg_flag = 2;                    }                    else                    {                        // 如果确认状态存在则审批级别设置为0 签收人                        if (applyInfoMap.get("qr_num") != null                            && Integer.valueOf(applyInfoMap.get("qr_num").toString()) > 0)                        {                            folFinaBill.setCurrent_level(0);                        }                        else                        {                            // 1草稿 2 审核中 3 待确认4 已完成 0已作废                            folFinaBill.setBill_state(3);                        }                    }                }            }            //如果状态为3则是待确认状态 需要给经办人和收付款人员发送提示消息            if (folFinaBill != null && folFinaBill.getBill_state() != null && folFinaBill.getBill_state() == 3)            {                send_msg_flag = 3;            }            FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();            // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据            approvalBean.setApproval_result(folApplyBillRelation.getApproval_state().toString());            // 审批意见            approvalBean.setApproval_advice(folApplyBillRelation.getApproval_advice());            // 流程节点code            approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_SP);            // 流程节点名称            approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_SP);            approvalBean.setFol_id(folFinaBill.getFol_fina_bill_id());            // 流程生成            generateApprovalBean(approvalBean, personnel);            /*// 直接更新审批人对应的单据状态和意见等 1同意 2驳回            if (folApplyBillRelation.getApproval_state().intValue() == 1)            {                // 此单据第一次审批                if (applyInfoMap.get("is_revoke") == null || "1".equals(applyInfoMap.get("is_revoke").toString()))                {                    BigDecimal coll_pay_amount = BigDecimal.ZERO;                    String bill_type = applyInfoMap.get("bill_type").toString();                    String reimburse_type = applyInfoMap.get("reimburse_type") != null ?                                            applyInfoMap.get("reimburse_type").toString() :                                            "";                    String charge_off_type = applyInfoMap.get("charge_off_type") != null ?                                             applyInfoMap.get("charge_off_type").toString() :                                             "";                    // 判断是否是报销单 charge_off_type'冲账方式 1 补充打款 2 还借款 3 全额冲账 4累加冲账', 补充打款和还借款需要计算一下                    // 可以直接取冲账差额                    if ("2".equals(bill_type) && "2".equals(reimburse_type))                    {                        //补充打款 还借款                        if (("1".equals(charge_off_type) || "2".equals(charge_off_type)))                        {                            coll_pay_amount = new BigDecimal(applyInfoMap.get("charge_off_diff_amount") != null ?                                                             applyInfoMap.get("charge_off_diff_amount").toString() :                                                             "0");                        }                        else if (("3".equals(charge_off_type) || "4".equals(charge_off_type)))                        {                            coll_pay_amount = BigDecimal.ZERO;                        }                    }                    else                    {                        coll_pay_amount = new BigDecimal(applyInfoMap.get("total_amount") != null ?                                                         applyInfoMap.get("total_amount").toString() :                                                         "0");                    }                    FolFinaBillSubsidiary folFinaBillSubsidiary = new FolFinaBillSubsidiary();                    folFinaBillSubsidiary.setColl_pay_amount(coll_pay_amount);                    folFinaBillSubsidiary.setFol_fina_bill_subsidiary_id(                            Integer.valueOf(applyInfoMap.get("fol_fina_bill_subsidiary_id").toString()));                    folFinaBillSubsidiaryDao.update(folFinaBillSubsidiary);                }            }*/            folApplyBillRelationDao.update(folApplyBillRelation);            folfinabillDao.update(folFinaBill);            List<FolFileBeanVO> fileList = new ArrayList<FolFileBeanVO>();            // 判断不为空 文件json            if (queryInfo.getFileJson() != null && !"".equals(queryInfo.getFileJson()))            {                fileList = JSON.parseArray(queryInfo.getFileJson(), FolFileBeanVO.class);            }			// 判断不为空 文件json			if (queryInfo.getImg_json() != null && !"".equals(queryInfo.getImg_json()))            {				FolFileBeanVO fileVo = JSON.parseObject(queryInfo.getImg_json(), FolFileBeanVO.class);				fileList.add(fileVo);            }            // 判断是否存在            if (fileList.size() > 0)            {                List<FolFileInfo> saveFileList = new ArrayList<>();                // 循环                for (FolFileBeanVO fileBeanVo : fileList)                {                    FolFileInfo folFileInfo = new FolFileInfo();                    folFileInfo.setAttachment_address(fileBeanVo.getUrl());                    folFileInfo.setAttachment_module(FOLMsgInfo.FILE_CODE_SPQM);                    folFileInfo.setAttachment_new_name(fileBeanVo.getUrl());                    folFileInfo.setAttachment_old_name(fileBeanVo.getOld_name());                    int index = fileBeanVo.getUrl().lastIndexOf(".");                    // 判断                    if (index > 0)                    {                        folFileInfo                                .setAttachment_type(fileBeanVo.getUrl().substring(index, fileBeanVo.getUrl().length()));                    }                    // 小类                    folFileInfo.setData_detail_name("qm");                    // 大类                    folFileInfo.setData_type_name("sp");                    folFileInfo.setEnable_flag(1);                    // 关联id                    folFileInfo.setFol_id(folFinaBill.getFol_fina_bill_id());                    folFileInfo.setFol_other_id(queryInfo.getFol_apply_bill_relation_id());                    saveFileList.add(folFileInfo);                }                folFileInfoDao.saveBatch(saveFileList);            }            // 直接更新审批人对应的单据状态和意见等 1同意 2驳回            if (folApplyBillRelation.getApproval_state().intValue() == 2)            {                // 单据类型 1借款 2费用报销 3出差报销                // 报销方式 1报销2冲账                if (applyInfoMap.get("bill_type") != null && "2".equals(applyInfoMap.get("bill_type").toString())                    && applyInfoMap.get("reimburse_type") != null                    && "2".equals(applyInfoMap.get("reimburse_type").toString()))                {                    //不为空                    if (applyInfoMap.get("fol_fina_bill_subsidiary_id_loans") != null)                    {                        // 循环                        for (String id_loan : applyInfoMap.get("fol_fina_bill_subsidiary_id_loans").toString()                                                          .split(","))                        {                            // 更新关联借款单的余额字段                            Map<String, Object> pMap = new HashMap<>();                            pMap.put("fol_fina_bill_subsidiary_id", id_loan);                            folFinaBillSubsidiaryDao.updateSubsidiaryBalanceAmount(pMap);                        }                    }                }            }            retMap.put("result", "success");            //1拒件 2 上级审批 3待确认            //send_msg_flag=2;            if (send_msg_flag != 0)            {                try                {                    // 如果是拒件                    if (send_msg_flag == 1)                    {                        // 发送微信消息                        Map<String, Object> param = new HashMap<>();                        List<Map<String, Object>> listUser = new ArrayList<>();                        Map<String, Object> map = new HashMap<>();                        map.put("personnel_shortCode", applyInfoMap.get("apply_user_shrotcode"));                        map.put("personnel_id", applyInfoMap.get("apply_user_id"));                        listUser.add(map);                        param.put("msg_code", "10004");                        param.put("bill_code", applyInfoMap.get("bill_code"));                        param.put("listUser", listUser);                        String approval_advice = folApplyBillRelation.getApproval_advice();                        // 判断意见是否存在 并且需要去除 拒件,                        if (approval_advice != null && approval_advice.length() >= 3)                        {                            approval_advice = folApplyBillRelation.getApproval_advice().substring(3,                                                                                                  folApplyBillRelation                                                                                                          .getApproval_advice()                                                                                                          .length());                        }                        param.put("approval_advice", approval_advice);                        param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_TZXX);                        // pc首页消息                        param.put("pcmsg_code", "20005");                        param.put("sys_code", "FOL");                        // 消息类型 1通知 2审批 3提醒                        param.put("message_type", "1");                        param.put("fol_id", folFinaBill.getFol_fina_bill_id());                        Map<String, Object> update_msg_param = new HashMap<>();                        update_msg_param.put("fol_id", folFinaBill.getFol_fina_bill_id());                        // 更新首页消息为已读                        sendWechatEmailMsgService.updateMsgRead(update_msg_param);                        // 发送微信消息                        sendWechatEmailMsgService.sendWechat(param);                    }                    else if (send_msg_flag == 2)                    {                        // 发送微信消息                        Map<String, Object> param = new HashMap<>();                        param.put("msg_code", "10001");                        param.put("bill_code", applyInfoMap.get("bill_code"));                        param.put("user_name_shortcode",                                  applyInfoMap.get("apply_user_name") + " " + applyInfoMap.get("apply_user_shrotcode"));                        param.put("fol_fina_bill_id", fol_fina_bill_id);                        param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_DSP);                        // pc首页消息                        param.put("pcmsg_code", "20003");                        param.put("sys_code", "FOL");                        // 消息类型 1通知 2审批 3提醒                        param.put("message_type", "2");                        param.put("fol_id", folFinaBill.getFol_fina_bill_id());                        Map<String, Object> update_msg_param = new HashMap<>();                        update_msg_param.put("fol_id", folFinaBill.getFol_fina_bill_id());                        // 更新首页消息为已读                        sendWechatEmailMsgService.updateMsgRead(update_msg_param);                        // 发送微信消息                        sendWechatEmailMsgService.sendWechat(param);                    }                    else if (send_msg_flag == 3)                    {                        try                        {                            // 发送微信消息 收付款确认                            Map<String, Object> param = new HashMap<>();                            param.put("msg_code", "10002");                            param.put("bill_code", applyInfoMap.get("bill_code"));                            param.put("user_name_shortcode",                                      applyInfoMap.get("apply_user_name") + " " +                                      applyInfoMap.get("apply_user_shrotcode"));                            param.put("role_num", "folsfkzy");                            param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_DQR);                            // pc首页消息                            param.put("pcmsg_code", "20004");                            param.put("sys_code", "FOL");                            // 消息类型 1通知 2审批 3提醒 4待确认                            param.put("message_type", "4");                            param.put("fol_id", folFinaBill.getFol_fina_bill_id());                            Map<String, Object> update_msg_param = new HashMap<>();                            update_msg_param.put("fol_id", folFinaBill.getFol_fina_bill_id());                            // 更新首页消息为已读                            sendWechatEmailMsgService.updateMsgRead(update_msg_param);                            // 发送微信消息                            sendWechatEmailMsgService.sendWechat(param);                        }                        catch (Exception e)                        {                            e.printStackTrace();                        }                        // 发送微信消息 通知经办人审批通过                        Map<String, Object> param1 = new HashMap<>();                        List<Map<String, Object>> listUser = new ArrayList<>();                        Map<String, Object> map = new HashMap<>();                        map.put("personnel_shortCode", applyInfoMap.get("apply_user_shrotcode"));                        map.put("personnel_id", applyInfoMap.get("apply_user_id"));                        listUser.add(map);                        param1.put("msg_code", "10003");                        param1.put("bill_code", applyInfoMap.get("bill_code"));                        param1.put("listUser", listUser);                        param1.put("approval_advice", folApplyBillRelation.getApproval_advice());                        param1.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_TZXX);                        // 是否是借款单                        if ("1".equals(applyInfoMap.get("bill_type").toString()))                        {                            // pc首页消息--借款单                            param1.put("pcmsg_code", "20001");                        }                        else                        {                            // pc首页消息--报销单                            param1.put("pcmsg_code", "20002");                        }                        param1.put("sys_code", "FOL");                        // 消息类型 1通知 2审批 3提醒 4待确认                        param1.put("message_type", "3");                        param1.put("fol_id", folFinaBill.getFol_fina_bill_id());                        // 发送微信消息                        sendWechatEmailMsgService.sendWechat(param1);                    }                    else if (send_msg_flag == 4)                    {                        Map<String, Object> update_msg_param = new HashMap<>();                        update_msg_param.put("fol_id", folFinaBill.getFol_fina_bill_id());                        update_msg_param.put("personnel_id", applyInfoMap.get("approval_user_id"));                        // 更新首页消息为已读                        sendWechatEmailMsgService.updateMsgRead(update_msg_param);                    }					// 直接更新审批人对应的单据状态和意见等 1同意 2驳回 审批后，通知经办人向财务部门交付相关票据					if (folApplyBillRelation.getApproval_state().intValue() == 1							&& applyInfoMap.containsKey("p_approval_type")							&& "2".equals(applyInfoMap.get("p_approval_type").toString()))                    {	                    try	                    {	                        // 发送微信消息 通知经办人审批通过	                        Map<String, Object> param1 = new HashMap<>();	                        List<Map<String, Object>> listUser = new ArrayList<>();	                        Map<String, Object> map = new HashMap<>();	                        map.put("personnel_shortCode", applyInfoMap.get("apply_user_shrotcode"));	                        map.put("personnel_id", applyInfoMap.get("apply_user_id"));	                        listUser.add(map);	                       // 是否是借款单	                        if ("1".equals(applyInfoMap.get("bill_type").toString()))	                        {	                        	 param1.put("msg_code", "10007");	                        }	                        else	                        {	                        	 param1.put("msg_code", "10008");	                        }	                        param1.put("bill_code", applyInfoMap.get("bill_code"));	                        param1.put("listUser", listUser);	                        param1.put("approval_advice", folApplyBillRelation.getApproval_advice());	                        param1.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_TZXX);	                        // 是否是借款单	                        if ("1".equals(applyInfoMap.get("bill_type").toString()))	                        {	                            // pc首页消息--借款单								param1.put("pcmsg_code", "20007");	                        }	                        else	                        {	                            // pc首页消息--报销单								param1.put("pcmsg_code", "20008");	                        }	                        param1.put("sys_code", "FOL");	                        // 消息类型 1通知 2审批 3提醒 4待确认	                        param1.put("message_type", "3");	                        param1.put("fol_id", folFinaBill.getFol_fina_bill_id());	                        // 发送微信消息	                        sendWechatEmailMsgService.sendWechat(param1);	                    }	                    catch (Exception e)	                    {	                        e.printStackTrace();	                    }                    }                }                catch (Exception e)                {                    e.printStackTrace();                }            }        }        else        {            // 提示其他人审批或者多次审批            retMap.put("result", "otherApply");        }        return retMap;    }    /**     * 方法名称: getReimburseInfo     * <p>     * 内容摘要:  获取报销单信息     *     * @param queryInfo     * @return     * @author: Baisong     * @time:2020年8月10日 下午4:06:33     */    @Override    public Map<String, Object> getReimburseInfo(FolFinaBillSearchBeanVO queryInfo)    {        Map<String, Object> retMap = new HashMap<>();        DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");        retMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());        List<Map<String, Object>> reimburseList = folfinabillDao.getConfirmReimburseInfo(retMap);		retMap.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);		retMap.put("fol_id", queryInfo.getFol_fina_bill_id());		List<Map<String, Object>> jkdFileList = folFileInfoDao.search(retMap);		// 判断		if (jkdFileList != null) 		{			retMap.put("jkdFileList", jkdFileList);		}		else 		{			retMap.put("jkdFileList", new ArrayList<Map<String, Object>>());		}        // 格式化金额        for (Map<String, Object> tmpMap : reimburseList)        {        	// 判断        	if(tmpMap.get("total_amount_reimburse") != null)        	{        		tmpMap.put("total_amount_reimburse",        				decimalFormat.format(new BigDecimal(tmpMap.get("total_amount_reimburse").toString())));        	}        	else        	{        		        	}        }        // 判断        if (reimburseList != null && reimburseList.size() > 0)        {            retMap.put("beseInfo", reimburseList.get(0));            retMap.put("beseInfoList", reimburseList);            retMap.put("fol_fina_bill_subsidiary_id", reimburseList.get(0).get("fol_fina_bill_subsidiary_id"));            List<Map<String, Object>> reimburseDetailList = folfinabillDao.getReimburseDetailInfo(retMap);            // 判断不为空            if (reimburseDetailList != null && reimburseDetailList.size() > 0)            {                reimburseList.get(0).put("reimburseDetailList", reimburseDetailList);            }        }        else        {            retMap.put("beseInfo", new HashMap<>());            retMap.put("beseInfoList", new ArrayList<>());            retMap.put("fol_fina_bill_subsidiary_id", null);        }        return retMap;    }    /**     * 方法名称: searchLoanApplicationBillsList     * 内容摘要: TODO(关联借款单-查询列表)     *     * @param queryInfo     * @return     * @author: wuguoqiang     * @time:2020年8月11日 下午4:06:42     */    @Override    public Map<String, Object> searchLoanApplicationBillsList(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            Map<String, Object> paramMap = new HashMap<String, Object>();            paramMap.put("apply_user_id", personnel.getPersonnel_id());            // 判断            if (StringUtils.isNotBlank(queryInfo.getBill_code()))            {                paramMap.put("bill_code", queryInfo.getBill_code());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getApply_date()))            {                paramMap.put("apply_date", queryInfo.getApply_date());            }            // 判断            if (queryInfo.getWrite_off_state_arr() != null && queryInfo.getWrite_off_state_arr().length > 0)            {                StringBuffer sb = new StringBuffer("(");                // 循环                for (String s : queryInfo.getWrite_off_state_arr())                {                    sb.append(s + ",");                }                sb = new StringBuffer(sb.toString().substring(0, sb.toString().length() - 1));                sb.append(")");                paramMap.put("write_off_state_arr", sb.toString());            }            paramMap.put("sortname", queryInfo.getSortname());            paramMap.put("sortorder", queryInfo.getSortorder());            paramMap.put("pagesize", queryInfo.getPagesize());            paramMap.put("offset", queryInfo.getOffset());            List<Map<String, Object>> list = folfinabillDao.searchLoanApplicationBillsList(paramMap);            GridDataBean<Map<String, Object>> bean = new GridDataBean<Map<String, Object>>(queryInfo.getPage(),                                                                                           folfinabillDao                                                                                                   .searchLoanApplicationBillsListCount(                                                                                                           paramMap),                                                                                           list);            resMap = bean.getGridData();        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * 方法名称: updateFolFinaBillReimburse     * 内容摘要: TODO(编辑报销)     *     * @param queryInfo     * @param personnel     * @return     * @author: wuguoqiang     * @time:2020年8月13日 上午10:48:17     */    @Override    @Transactional    public Map<String, Object> updateFolFinaBillReimburse(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            java.sql.Timestamp now_timestamp = new java.sql.Timestamp(System.currentTimeMillis());            String queryInfo_json = JSON.toJSONString(queryInfo);            FolFinaBill bean1 = new FolFinaBill();            com.zx.emanage.util.gen.BeanUtils.copyProperties(bean1, queryInfo);            // bean1.setApply_date(new java.sql.Date(now_timestamp.getTime()));            folfinabillDao.update(bean1);            // json转list            String list_str = queryInfo.getReimburseDetailList();            JSONArray arrayList = JSONArray.parseArray(list_str);            List<FolFinaBillReimburseDetail> reimburseDetailList = JSONObject.parseArray(arrayList.toJSONString(),                                                                                         FolFinaBillReimburseDetail.class);                        FolFinaBillSubsidiary bean2 = JSON.parseObject(queryInfo_json, new TypeReference<FolFinaBillSubsidiary>()            {            });            // 如果多条费用报销，详情表只保存一条            if (reimburseDetailList.size() > 1)            {                bean2.setBill_cause(reimburseDetailList.get(0).getReasons_cost() + "等");            }            else            {                bean2.setBill_cause(reimburseDetailList.get(0).getReasons_cost());            }                        // 判断是否为默认            if(queryInfo.getCard_default().equals("1"))            {            	bean2.setReceivables_bank(personnel.getPersonnel_bank_title());            	bean2.setReceivables_name(personnel.getPersonnel_name());            	bean2.setReceivables_bank_number(personnel.getPersonnel_bankCardCode());            	bean2.setReceivables_bank_branch(personnel.getPersonnel_bankName());            	bean2.setBank_num(personnel.getBank_num());            	bean2.setReceivables_bank_pro(personnel.getBank_province());            	bean2.setReceivables_bank_city(personnel.getBank_city());            }            else            {            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_pro()))            	{            		bean2.setReceivables_bank_pro(null);            	}            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_city()))            	{            		bean2.setReceivables_bank_city(null);            	}            }                    	bean2.setReceivables_bank_number(bean2.getReceivables_bank_number()!=null?bean2.getReceivables_bank_number().replace(" ",""):"");            folFinaBillSubsidiaryDao.update(bean2);            			Map<String, Object> paramMap = new HashMap<String, Object>();			paramMap.put("fol_fina_bill_subsidiary_id", bean2.getFol_fina_bill_subsidiary_id());			// 处理收付款金额			handleCollPayAmount(paramMap);            FolFinaBillReimburseDetail ffbrd = new FolFinaBillReimburseDetail();            ffbrd.setEnable_flag(0);            ffbrd.setFol_fina_bill_id(queryInfo.getFol_fina_bill_id());            ffbrd.setFol_fina_bill_subsidiary_id(queryInfo.getFol_fina_bill_subsidiary_id());            folfinabillreimbursedetaildao.delOriginalReimburseDetail(ffbrd);            // 循环插入            for (FolFinaBillReimburseDetail bean3 : reimburseDetailList)            {                bean3.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                bean3.setFol_fina_bill_subsidiary_id(bean2.getFol_fina_bill_subsidiary_id());                bean3.setCreate_timestamp(now_timestamp);                bean3.setCreate_user_id(personnel.getPersonnel_id());                bean3.setCreate_user_name(personnel.getPersonnel_name());                bean3.setCreate_user_shortcode(personnel.getPersonnel_shortCode());                bean3.setLast_update_timestamp(now_timestamp);                bean3.setLast_update_user_id(personnel.getPersonnel_id());                bean3.setEnable_flag(1);            }            folfinabillreimbursedetaildao.batchSave(reimburseDetailList);            FolFinaBillReimLoanRelation ffbrlr = new FolFinaBillReimLoanRelation();            ffbrlr.setFol_fina_bill_subsidiary_id_reim(bean2.getFol_fina_bill_subsidiary_id());            ffbrlr.setEnable_flag(0);            folfinabillreimloanrelationdao.update(ffbrlr);            //选择冲账时            if (queryInfo.getReimburse_type() != null && queryInfo.getReimburse_type() == 2)            {                // json转list                String loan_list_str = queryInfo.getRelationLoanBillList();                JSONArray loanArrayList = JSONArray.parseArray(loan_list_str);                List<FolFinaBillReimLoanRelation> relationLoanBillList = JSONObject                        .parseArray(loanArrayList.toJSONString(),                                    FolFinaBillReimLoanRelation.class);                // 循环插入                for (FolFinaBillReimLoanRelation bean4 : relationLoanBillList)                {                    bean4.setFol_fina_bill_subsidiary_id_reim(bean2.getFol_fina_bill_subsidiary_id());                    bean4.setEnable_flag(1);                }                folfinabillreimloanrelationdao.batchSave(relationLoanBillList);            }            Map<String,Object> paramFile=new HashMap<>();            paramFile.put("fol_id", bean1.getFol_fina_bill_id());            paramFile.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);            folFileInfoDao.batchDeleteForDJDY(paramFile);            // 判断            if(StringUtils.isNotEmpty(queryInfo.getFileJson()))            {            	List<FolFileInfo> file_list = JSON                        .parseObject(queryInfo.getFileJson(), new TypeReference<List<FolFileInfo>>()                        {                        });                // 循环                for (FolFileInfo bean_file : file_list)                {					bean_file.setFol_file_info_id(null);                    bean_file.setAttachment_module(FOLMsgInfo.FILE_CODE_DJSQ);                    bean_file.setData_type_name(FOLMsgInfo.FILE_CODE_DJSQ_T);                    bean_file.setData_detail_name(FOLMsgInfo.FILE_CODE_DJSQ_D);                    bean_file.setFol_id(bean1.getFol_fina_bill_id());                    bean_file.setFol_other_id(bean2.getFol_fina_bill_subsidiary_id());                    bean_file.setEnable_flag(1);                }              //判断                if(file_list!=null&&file_list.size()>0)                {    				this.folFileInfoDao.saveBatch(file_list);                }            }            			// 删除审批节点            paramMap.put("fol_fina_bill_id", bean1.getFol_fina_bill_id());            this.folApplyBillRelationDao.deleteFolApplyBillRelationByBillId(paramMap);            	            /**             * @param id  申请人             * @param bill_id 单据id             * @param apply_type 审批类型             * @param var 条件参数             */            List<FolApplyBillRelation> folApplyList =         		JSON.parseObject(queryInfo.getFlow_info_json(), new TypeReference<List<FolApplyBillRelation>>()                {                });            // 判断不为空            if (folApplyList != null && folApplyList.size() > 0)            {            	// 循环            	for(FolApplyBillRelation relation : folApplyList)            	{            		relation.setFol_apply_bill_relation_id(null);            		relation.setFol_fina_bill_id(bean1.getFol_fina_bill_id());            		relation.setApproval_type("1");            		relation.setEnable_flag(1);            		relation.setIsPhone("0");        		    relation.setLevel_flag("1");        		    relation.setApproval_state(0);            	}            	            	FolApplyBillRelation relation = this.addApprovalInfoForCWSP(folApplyList, bean1.getFol_fina_bill_id());            	// 判断            	if(relation != null)            	{            		folApplyList.add(relation);            	}            	                folApplyBillRelationServiceImpl.saveBatch(folApplyList, personnel);            }                        // 调用流程(1草稿 2 审核中 3 待签收4 已完成 0已作废)            if (bean1.getBill_state().intValue() == 2)            {                // 报销方式 1报销2冲账                if (bean2.getReimburse_type() != null && bean2.getReimburse_type() == 2)                {                    //不为空                    if (bean2.getFol_fina_bill_subsidiary_id() != null)                    {                        // 更新关联借款单的余额字段                        Map<String, Object> pMap = new HashMap<>();                        pMap.put("fol_fina_bill_subsidiary_id_reim", bean2.getFol_fina_bill_subsidiary_id());                        List<Map<String, Object>> listMap = folFinaBillReimLoanRelationDao                                .getReimLoanRelationInfo(pMap);                        // 是否为空                        if (listMap != null && listMap.size() > 0)                        {                            // 循环                            for (Map<String, Object> map : listMap)                            {                                pMap.put("fol_fina_bill_subsidiary_id", map.get("fol_fina_bill_subsidiary_id_loan"));                                folFinaBillSubsidiaryDao.updateSubsidiaryBalanceAmount(pMap);                            }                        }                    }                }                FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();                // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据                approvalBean.setApproval_result("4");                // 审批意见                approvalBean.setApproval_advice("提交成功。");                // 流程节点code                approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_TJ);                // 流程节点名称                approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_TJ);                approvalBean.setFol_id(bean1.getFol_fina_bill_id());                // 流程生成                generateApprovalBean(approvalBean, personnel);                try                {					FolFinaBill bean_info = folfinabillDao.get(bean1.getFol_fina_bill_id());                    // 发送微信消息                    Map<String, Object> param = new HashMap<>();                    param.put("msg_code", "10001");					param.put("fol_fina_bill_id", bean_info.getFol_fina_bill_id());					param.put("bill_code", bean_info.getBill_code());                    param.put("user_name_shortcode",							bean_info.getApply_user_name() + " " + bean_info.getApply_user_shrotcode());                    param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_DSP);                    // pc首页消息                    param.put("pcmsg_code", "20003");                    param.put("sys_code", "FOL");                    // 消息类型 1通知 2审批 3提醒 4待确认                    param.put("message_type", "2");					param.put("fol_id", bean_info.getFol_fina_bill_id());                    // 发送微信消息                    sendWechatEmailMsgService.sendWechat(param);                }                catch (Exception e)                {                    e.printStackTrace();                }            }        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();            // 回滚事务            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * 方法名称: getTripInfo     * <p>     * 内容摘要: 获取差旅报销单信息     *     * @param queryInfo     * @return     * @author: Baisong     * @time:2020年8月11日 上午11:58:11     */    @Override    public Map<String, Object> getTripInfo(FolFinaBillSearchBeanVO queryInfo)    {        Map<String, Object> retMap = new HashMap<>();        List<Map<String, Object>> reimburseList = new ArrayList<>();        // 判断不为空        if (queryInfo.getFol_apply_bill_relation_id() != null)        {            retMap.put("fol_apply_bill_relation_id", queryInfo.getFol_apply_bill_relation_id());            reimburseList = folfinabillDao.getTripInfo(retMap);			// 判断			if (reimburseList.size() > 0 && reimburseList.get(0).get("fol_fina_bill_id") != null) 			{				queryInfo.setFol_fina_bill_id(Integer.valueOf(reimburseList.get(0).get("fol_fina_bill_id").toString()));			}        }        else        {            retMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());            reimburseList = folfinabillDao.getConfirmTripInfo(retMap);        }        // 判断        if (reimburseList != null && reimburseList.size() > 0)        {            retMap.put("beseInfo", reimburseList.get(0));            retMap.put("fol_fina_bill_subsidiary_id", reimburseList.get(0).get("fol_fina_bill_subsidiary_id"));            List<Map<String, Object>> tripDetailList = folfinabillDao.getTripDetailInfo(retMap);            // 判断不为空            if (tripDetailList != null && tripDetailList.size() > 0)            {                reimburseList.get(0).put("tripDetailList", tripDetailList);            }        }        else        {            retMap.put("beseInfo", new HashMap<>());        }		Map<String, Object> fileParamMap = new HashMap<String, Object>();		fileParamMap.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);		fileParamMap.put("fol_id", queryInfo.getFol_fina_bill_id());		List<Map<String, Object>> jkdFileList = folFileInfoDao.search(fileParamMap);        // 判断        if(jkdFileList != null)        {        	retMap.put("jkdFileList", jkdFileList);        }        else        {        	retMap.put("jkdFileList", new ArrayList<Map<String, Object>>());        }        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd ");        retMap.put("confirm_date", sd.format(new java.sql.Date(System.currentTimeMillis())));        return retMap;    }    /**     * 方法名称: generateApprovalBean     * 内容摘要: 生成流程     *     * @author: Baisong     * @time:2020年8月11日 下午4:14:41     */    public void generateApprovalBean(FolCreApprovalInfo approvalBean, PmPersonnel personnel)    {        // 流程模块        approvalBean.setApproval_module(FOLMsgInfo.APPROVAL_MODULE_CWSP);        // 流程节点名称        approvalBean.setApproval_time(new Timestamp(System.currentTimeMillis()));        //判断是否是驳回        if ("2".equals(approvalBean.getApproval_result()))        {            approvalBean.setApproval_type(FOLMsgInfo.APPROVAL_TYPE_JJ);        }        //判断是否是撤销        else if ("0".equals(approvalBean.getApproval_result()))        {            // 撤销            approvalBean.setApproval_type(FOLMsgInfo.APPROVAL_TYPE_CH);        }        else        {            //通过            approvalBean.setApproval_type(FOLMsgInfo.APPROVAL_TYPE_TG);        }        approvalBean.setApproval_user_deptId(personnel.getPersonnel_deptId());        approvalBean.setApproval_user_deptName(personnel.getPersonnel_deptName());        approvalBean.setApproval_user_id(personnel.getPersonnel_id());        approvalBean.setApproval_user_name(personnel.getPersonnel_name());        approvalBean.setApproval_user_postNub(personnel.getPersonnel_postName());        approvalBean.setApproval_user_shortcode(personnel.getPersonnel_shortCode());        approvalBean.setEnable_flag(1);        folCreApprovalInfoDao.save(approvalBean);    }    /**     * 方法名称: getFolFinaBillTravelById     * 内容摘要: TODO(差旅费模态框)     *     * @param queryInfo     * @param personnel     * @return     * @author: wuguoqiang     * @time:2020年8月17日 下午3:43:35     */    @Override    public Map<String, Object> getFolFinaBillTravelById(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        Map<String, Object> resMap = new HashMap<String, Object>();        Map<String, Object> paramMap = new HashMap<String, Object>();        Map<String, Object> tmpMap = new HashMap<String, Object>();        // 不为0则为编辑        if (queryInfo.getFol_fina_bill_id() != null && queryInfo.getFol_fina_bill_id() != 0)        {            paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());            paramMap.put("fol_fina_bill_subsidiary_id", queryInfo.getFol_fina_bill_subsidiary_id());            paramMap.put("sortorder", "asc");            paramMap.put("sortname", "fol_fina_bill_business_trip_detail_id");            List<Map<String, Object>> list = folfinabillbusinesstripdetaildao.search(paramMap);            DecimalFormat df = new DecimalFormat("#.##");            BigDecimal zero = new BigDecimal("0");            // 将费用类型格式化为List<Map<String, Object>>            for (Map<String, Object> m : list)            {                List<Map<String, Object>> cost_type_arr = new ArrayList<>();                // 判断长途费用是否有值                if (new BigDecimal(m.get("longDistance_cost").toString()).compareTo(zero) == 1)                {                    Map<String, Object> cost_type_map = new HashMap<>();                    cost_type_map.put("cost_type", "longDistance_cost");                    cost_type_map.put("cost", df.format(new BigDecimal(m.get("longDistance_cost").toString())));                    cost_type_arr.add(cost_type_map);                }                // 判断市内交通费用是否有值                if (new BigDecimal(m.get("city_cost").toString()).compareTo(zero) == 1)                {                    Map<String, Object> cost_type_map = new HashMap<>();                    cost_type_map.put("cost_type", "city_cost");                    cost_type_map.put("cost", df.format(new BigDecimal(m.get("city_cost").toString())));                    cost_type_arr.add(cost_type_map);                }                // 判断住宿费是否有值                if (new BigDecimal(m.get("hotel_cost").toString()).compareTo(zero) == 1)                {                    Map<String, Object> cost_type_map = new HashMap<>();                    cost_type_map.put("cost_type", "hotel_cost");                    cost_type_map.put("cost", df.format(new BigDecimal(m.get("hotel_cost").toString())));                    cost_type_arr.add(cost_type_map);                }                // 判断伙食费是否有值                if (new BigDecimal(m.get("meals_cost").toString()).compareTo(zero) == 1)                {                    Map<String, Object> cost_type_map = new HashMap<>();                    cost_type_map.put("cost_type", "meals_cost");                    cost_type_map.put("cost", df.format(new BigDecimal(m.get("meals_cost").toString())));                    cost_type_arr.add(cost_type_map);                }                // 判断其他费用是否有值                if (new BigDecimal(m.get("other_cost").toString()).compareTo(zero) == 1)                {                    Map<String, Object> cost_type_map = new HashMap<>();                    cost_type_map.put("cost_type", "other_cost");                    cost_type_map.put("cost", df.format(new BigDecimal(m.get("other_cost").toString())));                    cost_type_arr.add(cost_type_map);                }                // 配置费用类型删除键是否隐藏                for (int i = 1; i < cost_type_arr.size(); i++)                {                    cost_type_arr.get(i - 1).put("hide", true);                }                m.put("cost_type_arr", cost_type_arr);            }            tmpMap.put("travelDetailList", list);            FolFinaBillSubsidiary ffbs = folFinaBillSubsidiaryDao.get(queryInfo.getFol_fina_bill_subsidiary_id());            FolFinaBill ffb = folfinabillDao.get(queryInfo.getFol_fina_bill_id());            tmpMap.put("total_amount", ffbs.getTotal_amount());            tmpMap.put("bill_cause", ffbs.getBill_cause());            tmpMap.put("business_trip_startdate", ffbs.getBusiness_trip_startdate());            tmpMap.put("business_trip_enddate", ffbs.getBusiness_trip_enddate());            tmpMap.put("business_trip_days_total", ffbs.getBusiness_trip_days_total());            tmpMap.put("business_trip_bill", ffbs.getBusiness_trip_bill());            tmpMap.put("apply_date", ffb.getApply_date());            // 处理同行人数据            Map<String, Object> business_trip_users_param = new HashMap<>();            business_trip_users_param.put("business_trip_users", ffbs.getBusiness_trip_users());            List<Map<String, Object>> business_trip_users_list = pmpersonneldao                    .getPersonnelListForBusinessTrip(business_trip_users_param);            List<Map<String, Object>> tags = new ArrayList<>();            // 循环            for (Map<String, Object> business_trip_users_map : business_trip_users_list)            {                Map<String, Object> tag = new HashMap<>();                tag.put("personnel_id", business_trip_users_map.get("personnel_id"));                tag.put("personnel_name_str", business_trip_users_map.get("personnel_name_str"));                tags.add(tag);            }            tmpMap.put("tags", tags);            tmpMap.put("receivables_name", ffbs.getReceivables_name());            tmpMap.put("receivables_bank", ffbs.getReceivables_bank());            tmpMap.put("receivables_bank_branch", ffbs.getReceivables_bank_branch());            tmpMap.put("receivables_bank_number", ffbs.getReceivables_bank_number());            tmpMap.put("receivables_bank_pro", ffbs.getReceivables_bank_pro());            tmpMap.put("receivables_bank_city", ffbs.getReceivables_bank_city());            tmpMap.put("bank_num", ffbs.getBank_num());            tmpMap.put("receivables_bank_pro_str", ffbs.getReceivables_bank_pro_str());            tmpMap.put("receivables_bank_city_str", ffbs.getReceivables_bank_city_str());            tmpMap.put("suffix_pro", ffbs.getSuffix_pro());            tmpMap.put("suffix_city", ffbs.getSuffix_city());                        resMap.put("card_default", ffbs.getCard_default().toString());        }        else        {            Map<String, Object> map = new HashMap<String, Object>();            map.put("business_trip_date", "");            map.put("business_trip_days", "");            map.put("start_address", "");            map.put("end_address", "");            map.put("total_cost", "");            Map<String, Object> cost_map = new HashMap<String, Object>();            List<Map<String, Object>> cost_list = new ArrayList<Map<String, Object>>();            cost_map.put("cost_type", "");            cost_map.put("cost", "");            cost_list.add(cost_map);            map.put("cost_type_arr", cost_list);            List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();            list.add(map);            tmpMap.put("travelDetailList", list);            //tmpMap.put("business_trip_days_total", 1);            resMap.put("card_default", "1");        }        // 判断        if(resMap.get("card_default") == null || resMap.get("card_default").toString().equals("1"))        {        	tmpMap.put("receivables_name", personnel.getPersonnel_name());        	tmpMap.put("receivables_bank", personnel.getPersonnel_bank_title());        	tmpMap.put("receivables_bank_branch", personnel.getPersonnel_bankName());        	tmpMap.put("receivables_bank_number", personnel.getPersonnel_bankCardCode());        	tmpMap.put("receivables_bank_pro", personnel.getBank_province());        	tmpMap.put("receivables_bank_city", personnel.getBank_city());        	tmpMap.put("bank_num", personnel.getBank_num());        	tmpMap.put("receivables_bank_pro_str", personnel.getBank_province_str());        	tmpMap.put("receivables_bank_city_str", personnel.getBank_city_str());        	tmpMap.put("suffix_pro", personnel.getSuffix_pro());        	tmpMap.put("suffix_city", personnel.getSuffix_city());        }                tmpMap.put("default_receivables_name", personnel.getPersonnel_name());    	tmpMap.put("default_receivables_bank", personnel.getPersonnel_bank_title());    	tmpMap.put("default_receivables_bank_branch", personnel.getPersonnel_bankName());    	tmpMap.put("default_receivables_bank_number", personnel.getPersonnel_bankCardCode());    	tmpMap.put("default_receivables_bank_pro", personnel.getBank_province());    	tmpMap.put("default_receivables_bank_city", personnel.getBank_city());    	tmpMap.put("default_bank_num", personnel.getBank_num());    	tmpMap.put("default_receivables_bank_pro_str", personnel.getBank_province_str());    	tmpMap.put("default_receivables_bank_city_str", personnel.getBank_city_str());    	Map<String, Object> fileParamMap = new HashMap<String, Object>();		fileParamMap.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);		fileParamMap.put("fol_id", queryInfo.getFol_fina_bill_id());		List<Map<String, Object>> jkdFileList = folFileInfoDao.search(fileParamMap);        // 判断        if(jkdFileList != null)        {        	resMap.put("jkdFileList", jkdFileList);        }        else        {        	resMap.put("jkdFileList", new ArrayList<Map<String, Object>>());        }        resMap.put("user", personnel);        resMap.put("bean", tmpMap);                Date date = new Date();        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");        resMap.put("now_date", format.format(date));        return resMap;    }    /**     * 方法名称: addFolFinaBillBusinessTrip     * 内容摘要: TODO(新增差旅报销)     *     * @param queryInfo     * @param personnel     * @return     * @author: wuguoqiang     * @time:2020年8月18日 下午5:48:05     */    @Override    @Transactional    public Map<String, Object> addFolFinaBillBusinessTrip(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            java.sql.Timestamp now_timestamp = new java.sql.Timestamp(System.currentTimeMillis());            String queryInfo_json = JSON.toJSONString(queryInfo);                        FolFinaBill bean1 = new FolFinaBill();            com.zx.emanage.util.gen.BeanUtils.copyProperties(bean1, queryInfo);            bean1.setBill_code(CodeNoUtil.getReimburseCode());            bean1.setApply_date(new java.sql.Date(now_timestamp.getTime()));            bean1.setApply_user_id(personnel.getPersonnel_id());            bean1.setApply_user_name(personnel.getPersonnel_name());            bean1.setApply_user_shrotcode(personnel.getPersonnel_shortCode());            bean1.setApply_user_postname(personnel.getPersonnel_postName());            bean1.setApply_user_postid(personnel.getPersonnel_postId());            bean1.setApply_user_deptid(personnel.getPersonnel_deptId());            bean1.setApply_user_deptname(personnel.getPersonnel_deptName());            bean1.setApply_user_pdeptid(personnel.getDept_pid());            bean1.setApply_user_pdeptname(personnel.getDept_pname());            bean1.setBill_type(queryInfo.getBill_type());            // 审批当前级别            bean1.setCurrent_level(1);            // 是否可以撤销 1可以 0不可以            bean1.setIs_revoke(1);            bean1.setCreate_timestamp(now_timestamp);            bean1.setCreate_user_id(personnel.getPersonnel_id());            bean1.setCreate_user_name(personnel.getPersonnel_name());            bean1.setCreate_user_shortcode(personnel.getPersonnel_shortCode());            bean1.setLast_update_timestamp(now_timestamp);            bean1.setLast_update_user_id(personnel.getPersonnel_id());            bean1.setEnable_flag(1);            folfinabillDao.save(bean1);            FolFinaBillSubsidiary bean2 = JSON.parseObject(queryInfo_json, new TypeReference<FolFinaBillSubsidiary>()            {            });                        bean2.setFol_fina_bill_id(bean1.getFol_fina_bill_id());           /* bean2.setReceivables_bank(personnel.getPersonnel_bank_title());            bean2.setReceivables_name(personnel.getPersonnel_name());            bean2.setReceivables_bank_number(personnel.getPersonnel_bankCardCode()!=null?  personnel.getPersonnel_bankCardCode().replace(" ", ""):"");            bean2.setReceivables_bank_branch(personnel.getPersonnel_bankName());            bean2.setBank_num(personnel.getBank_num());*/            // 报销            bean2.setReimburse_type(1);            bean2.setEnable_flag(1);                        // 判断是否为默认            if(queryInfo.getCard_default().equals("1"))            {            	bean2.setReceivables_bank(personnel.getPersonnel_bank_title());            	bean2.setReceivables_name(personnel.getPersonnel_name());            	bean2.setReceivables_bank_number(personnel.getPersonnel_bankCardCode());            	bean2.setReceivables_bank_branch(personnel.getPersonnel_bankName());            	bean2.setBank_num(personnel.getBank_num());            	bean2.setReceivables_bank_pro(personnel.getBank_province());            	bean2.setReceivables_bank_city(personnel.getBank_city());            }            bean2.setReceivables_bank_number(bean2.getReceivables_bank_number()!=null?  bean2.getReceivables_bank_number().replace(" ", ""):"");			bean2.setColl_pay_amount(bean2.getTotal_amount());            folFinaBillSubsidiaryDao.save(bean2);            // json转list            String list_str = queryInfo.getTravelDetailList();            JSONArray arrayList = JSONArray.parseArray(list_str);            List<FolFinaBillBusinessTripDetail> businessTripDetailList = JSONObject.parseArray(arrayList.toJSONString(),                                                                                               FolFinaBillBusinessTripDetail.class);            // 循环插入            for (FolFinaBillBusinessTripDetail bean3 : businessTripDetailList)            {                bean3.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                bean3.setFol_fina_bill_subsidiary_id(bean2.getFol_fina_bill_subsidiary_id());                bean3.setCreate_timestamp(now_timestamp);                bean3.setCreate_user_id(personnel.getPersonnel_id());                bean3.setCreate_user_name(personnel.getPersonnel_name());                bean3.setCreate_user_shortcode(personnel.getPersonnel_shortCode());                bean3.setLast_update_timestamp(now_timestamp);                bean3.setLast_update_user_id(personnel.getPersonnel_id());                bean3.setEnable_flag(1);            }            folfinabillbusinesstripdetaildao.batchSave(businessTripDetailList);            // 判断            if(StringUtils.isNotEmpty(queryInfo.getFileJson()))            {            	List<FolFileInfo> file_list = JSON                        .parseObject(queryInfo.getFileJson(), new TypeReference<List<FolFileInfo>>()                        {                        });                // 循环                for (FolFileInfo bean_file : file_list)                {                	bean_file.setFol_file_info_id(null);                    bean_file.setAttachment_module(FOLMsgInfo.FILE_CODE_DJSQ);                    bean_file.setData_type_name(FOLMsgInfo.FILE_CODE_DJSQ_T);                    bean_file.setData_detail_name(FOLMsgInfo.FILE_CODE_DJSQ_D);                    bean_file.setFol_id(bean1.getFol_fina_bill_id());                    bean_file.setFol_other_id(bean2.getFol_fina_bill_subsidiary_id());                    bean_file.setEnable_flag(1);                }              //判断                if(file_list!=null&&file_list.size()>0)                {    				this.folFileInfoDao.saveBatch(file_list);                }            }                        /**             * @param id  申请人             * @param bill_id 单据id             * @param apply_type 审批类型             * @param var 条件参数             */            List<FolApplyBillRelation> folApplyList =         		JSON.parseObject(queryInfo.getFlow_info_json(), new TypeReference<List<FolApplyBillRelation>>()                {                });            // 判断不为空            if (folApplyList != null && folApplyList.size() > 0)            {            	// 循环            	for(FolApplyBillRelation relation : folApplyList)            	{            		relation.setFol_apply_bill_relation_id(null);            		relation.setFol_fina_bill_id(bean1.getFol_fina_bill_id());            		relation.setApproval_type("1");            		relation.setEnable_flag(1);            		relation.setIsPhone("0");        		    relation.setLevel_flag("1");        		    relation.setApproval_state(0);            	}            	            	FolApplyBillRelation relation = this.addApprovalInfoForCWSP(folApplyList, bean1.getFol_fina_bill_id());            	// 判断            	if(relation != null)            	{            		folApplyList.add(relation);            	}            	                folApplyBillRelationServiceImpl.saveBatch(folApplyList, personnel);            }                        // 调用流程(1草稿 2 审核中 3 待签收4 已完成 0已作废)            if (bean1.getBill_state().intValue() == 2)            {                FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();                // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据                approvalBean.setApproval_result("4");                // 审批意见                approvalBean.setApproval_advice("提交成功。");                // 流程节点code                approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_TJ);                // 流程节点名称                approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_TJ);                approvalBean.setFol_id(bean1.getFol_fina_bill_id());                // 流程生成                generateApprovalBean(approvalBean, personnel);                try                {                    // 发送微信消息                    Map<String, Object> param = new HashMap<>();                    param.put("msg_code", "10001");                    param.put("fol_fina_bill_id", bean1.getFol_fina_bill_id());                    param.put("bill_code", bean1.getBill_code());                    param.put("user_name_shortcode",                              bean1.getApply_user_name() + " " + bean1.getApply_user_shrotcode());                    param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_DSP);                    // pc首页消息                    param.put("pcmsg_code", "20003");                    param.put("sys_code", "FOL");                    // 消息类型 1通知 2审批 3提醒 4待确认                    param.put("message_type", "2");                    param.put("fol_id", bean1.getFol_fina_bill_id());                    sendWechatEmailMsgService.sendWechat(param);                }                catch (Exception e)                {                    e.printStackTrace();                }            }        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();            // 回滚事务            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * 方法名称: getPersonnelListForBusinessTrip     * 内容摘要: TODO(添加出差同行人列表)     *     * @param queryInfo     * @return     * @author: wuguoqiang     * @time:2020年8月20日 下午2:26:43     */    @Override    public Map<String, Object> getPersonnelListForBusinessTrip(FolFinaBillSearchBeanVO queryInfo)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            Map<String, Object> paramMap = new HashMap<String, Object>();            // 判断            if (StringUtils.isNotBlank(queryInfo.getPersonnel_deptName()))            {                paramMap.put("personnel_deptName", queryInfo.getPersonnel_deptName());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getPersonnel_name_str()))            {                paramMap.put("personnel_name_str", queryInfo.getPersonnel_name_str());                paramMap.put("personnel_name", queryInfo.getPersonnel_name_str());                paramMap.put("personnel_shortCode", queryInfo.getPersonnel_name_str());            }            // 判断            if (StringUtils.isNotBlank(queryInfo.getPersonnel_state()))            {                paramMap.put("personnel_state", queryInfo.getPersonnel_state());            }            paramMap.put("sortname", queryInfo.getSortname());            paramMap.put("sortorder", queryInfo.getSortorder());            paramMap.put("pagesize", queryInfo.getPagesize());            paramMap.put("offset", queryInfo.getOffset());            List<Map<String, Object>> list = pmpersonneldao.getPersonnelListForBusinessTrip(paramMap);            GridDataBean<Map<String, Object>> bean =                    new GridDataBean<Map<String, Object>>(queryInfo.getPage(),                                                          pmpersonneldao.getPersonnelListForBusinessTripCount(paramMap),                                                          list);            resMap = bean.getGridData();        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * 方法名称: updateFolFinaBillBusinessTrip     * 内容摘要: TODO(编辑差旅报销)     *     * @param queryInfo     * @param personnel     * @return     * @author: wuguoqiang     * @time:2020年8月21日 上午9:11:31     */    @Override    @Transactional    public Map<String, Object> updateFolFinaBillBusinessTrip(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        String ret_code = ResultHelper.RET_SUCCESS;        Map<String, Object> resMap = new HashMap<String, Object>();        try        {            java.sql.Timestamp now_timestamp = new java.sql.Timestamp(System.currentTimeMillis());            String queryInfo_json = JSON.toJSONString(queryInfo);                        FolFinaBill bean1 = new FolFinaBill();            com.zx.emanage.util.gen.BeanUtils.copyProperties(bean1, queryInfo);            // bean1.setApply_date(new java.sql.Date(now_timestamp.getTime()));            folfinabillDao.update(bean1);            FolFinaBillSubsidiary bean2 = JSON.parseObject(queryInfo_json, new TypeReference<FolFinaBillSubsidiary>()            {            });                        // 判断是否为默认            if(queryInfo.getCard_default().equals("1"))            {            	bean2.setReceivables_bank(personnel.getPersonnel_bank_title());            	bean2.setReceivables_name(personnel.getPersonnel_name());            	bean2.setReceivables_bank_number(personnel.getPersonnel_bankCardCode());            	bean2.setReceivables_bank_branch(personnel.getPersonnel_bankName());            	bean2.setBank_num(personnel.getBank_num());            	bean2.setReceivables_bank_pro(personnel.getBank_province());            	bean2.setReceivables_bank_city(personnel.getBank_city());            }            else            {            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_pro()))            	{            		bean2.setReceivables_bank_pro(null);            	}            	// 判断            	if(StringUtils.isEmpty(bean2.getReceivables_bank_city()))            	{            		bean2.setReceivables_bank_city(null);            	}            }                        bean2.setReceivables_bank_number(bean2.getReceivables_bank_number()!=null?  bean2.getReceivables_bank_number().replace(" ", ""):"");			bean2.setColl_pay_amount(bean2.getTotal_amount());            folFinaBillSubsidiaryDao.update(bean2);            FolFinaBillBusinessTripDetail ffbbtd = new FolFinaBillBusinessTripDetail();            ffbbtd.setEnable_flag(0);            ffbbtd.setFol_fina_bill_id(queryInfo.getFol_fina_bill_id());            ffbbtd.setFol_fina_bill_subsidiary_id(queryInfo.getFol_fina_bill_subsidiary_id());            folfinabillbusinesstripdetaildao.delOriginalBusinessTripDetail(ffbbtd);            // json转list            String list_str = queryInfo.getTravelDetailList();            JSONArray arrayList = JSONArray.parseArray(list_str);            List<FolFinaBillBusinessTripDetail> businessTripDetailList = JSONObject.parseArray(arrayList.toJSONString(),                                                                                               FolFinaBillBusinessTripDetail.class);            // 循环插入            for (FolFinaBillBusinessTripDetail bean3 : businessTripDetailList)            {                bean3.setFol_fina_bill_id(bean1.getFol_fina_bill_id());                bean3.setFol_fina_bill_subsidiary_id(bean2.getFol_fina_bill_subsidiary_id());                bean3.setCreate_timestamp(now_timestamp);                bean3.setCreate_user_id(personnel.getPersonnel_id());                bean3.setCreate_user_name(personnel.getPersonnel_name());                bean3.setCreate_user_shortcode(personnel.getPersonnel_shortCode());                bean3.setLast_update_timestamp(now_timestamp);                bean3.setLast_update_user_id(personnel.getPersonnel_id());                bean3.setEnable_flag(1);            }            folfinabillbusinesstripdetaildao.batchSave(businessTripDetailList);			Map<String, Object> fileParamMap = new HashMap<String, Object>();			// 删除附件			fileParamMap.put("fol_id", bean1.getFol_fina_bill_id());			fileParamMap.put("attachment_module", FOLMsgInfo.FILE_CODE_DJSQ);			this.folFileInfoDao.deleteFilesForDJSQ(fileParamMap);                        // 判断            if(StringUtils.isNotEmpty(queryInfo.getFileJson()))            {            	List<FolFileInfo> file_list = JSON                        .parseObject(queryInfo.getFileJson(), new TypeReference<List<FolFileInfo>>()                        {                        });                // 循环                for (FolFileInfo bean_file : file_list)                {                	bean_file.setFol_file_info_id(null);                    bean_file.setAttachment_module(FOLMsgInfo.FILE_CODE_DJSQ);                    bean_file.setData_type_name(FOLMsgInfo.FILE_CODE_DJSQ_T);                    bean_file.setData_detail_name(FOLMsgInfo.FILE_CODE_DJSQ_D);                    bean_file.setFol_id(bean1.getFol_fina_bill_id());                    bean_file.setFol_other_id(bean2.getFol_fina_bill_subsidiary_id());                    bean_file.setEnable_flag(1);                }              //判断                if(file_list!=null&&file_list.size()>0)                {    				this.folFileInfoDao.saveBatch(file_list);                }            }                        Map<String, Object> paramMap = new HashMap<String, Object>();			// 删除审批节点            paramMap.put("fol_fina_bill_id", bean1.getFol_fina_bill_id());            this.folApplyBillRelationDao.deleteFolApplyBillRelationByBillId(paramMap);            	            /**             * @param id  申请人             * @param bill_id 单据id             * @param apply_type 审批类型             * @param var 条件参数             */            List<FolApplyBillRelation> folApplyList =         		JSON.parseObject(queryInfo.getFlow_info_json(), new TypeReference<List<FolApplyBillRelation>>()                {                });            // 判断不为空            if (folApplyList != null && folApplyList.size() > 0)            {            	// 循环            	for(FolApplyBillRelation relation : folApplyList)            	{            		relation.setFol_apply_bill_relation_id(null);            		relation.setFol_fina_bill_id(bean1.getFol_fina_bill_id());            		relation.setApproval_type("1");            		relation.setEnable_flag(1);            		relation.setIsPhone("0");        		    relation.setLevel_flag("1");        		    relation.setApproval_state(0);            	}            	            	FolApplyBillRelation relation = this.addApprovalInfoForCWSP(folApplyList, bean1.getFol_fina_bill_id());            	// 判断            	if(relation != null)            	{            		folApplyList.add(relation);            	}            	                folApplyBillRelationServiceImpl.saveBatch(folApplyList, personnel);            }                        // 调用流程(1草稿 2 审核中 3 待签收4 已完成 0已作废)            if (bean1.getBill_state().intValue() == 2)            {                FolCreApprovalInfo approvalBean = new FolCreApprovalInfo();                // 流程审批结果 0 单据撤销 1审批通过 2审批拒件 3 财务确认 4提交单据                approvalBean.setApproval_result("4");                // 审批意见                approvalBean.setApproval_advice("提交成功。");                // 流程节点code                approvalBean.setApproval_task_code(FOLMsgInfo.APPROVAL_TASK_CODE_TJ);                // 流程节点名称                approvalBean.setApproval_task_name(FOLMsgInfo.APPROVAL_TASK_NAME_TJ);                approvalBean.setFol_id(bean1.getFol_fina_bill_id());                // 流程生成                generateApprovalBean(approvalBean, personnel);                try                {					FolFinaBill bean_info = folfinabillDao.get(bean1.getFol_fina_bill_id());                    // 发送微信消息                    Map<String, Object> param = new HashMap<>();                    param.put("msg_code", "10001");					param.put("fol_fina_bill_id", bean_info.getFol_fina_bill_id());					param.put("bill_code", bean_info.getBill_code());                    param.put("user_name_shortcode",							bean_info.getApply_user_name() + " " + bean_info.getApply_user_shrotcode());                    param.put("keyword1", FOLMsgInfo.APPROVAL_TYPE_DSP);                    // pc首页消息                    param.put("pcmsg_code", "20003");                    param.put("sys_code", "FOL");                    // 消息类型 1通知 2审批 3提醒 4待确认                    param.put("message_type", "2");					param.put("fol_id", bean_info.getFol_fina_bill_id());                    sendWechatEmailMsgService.sendWechat(param);                }                catch (Exception e)                {                    e.printStackTrace();                }            }        }        catch (Exception e)        {            ret_code = ResultHelper.RET_ERROR;            e.printStackTrace();            // 回滚事务            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();        }        return ResultHelper.getReturnData(resMap, ret_code, "");    }    /**     * 方法名称: getSysDataInfoList     * <p>     * 内容摘要: 移动端获取码表     *     * @param queryInfo     * @param personnel     * @return     * @author: Baisong     * @time:2020年10月10日 下午1:14:42     */    @Override    public Map<String, Object> getSysDataInfoList(FolmDataBeanVO queryInfo)    {        Map<String, Object> retMap = new HashMap<>();        //判断传递的参数不为空        if (queryInfo.getData_code() != null && !"".equals(queryInfo.getData_code()))        {            String codes[] = queryInfo.getData_code().split(",");            //循环获取            for (String code : codes)            {                //不为空                if (!"".equals(code.trim()))                {                    Map<String, Object> paramMap = new HashMap<>();					switch (code)					{					// 101：所属城市（省） //102：所属城市（市）					case "101":						paramMap.put("code", "0");						List<Map<String, Object>> sysProDataList = districtDao.getDistrictList(paramMap);						retMap.put(code, sysProDataList);						break;					case "102":						paramMap.put("code", queryInfo.getData_code_detailed());						List<Map<String, Object>> sysCityDataList = districtDao.getDistrictList(paramMap);						retMap.put(code, sysCityDataList);						break;					default:						paramMap.put("fol_sys_dict_id", code);						// 如果是冲账状态则不需要冲账完成						if ("2".equals(code)) 						{							// m1为移动端 第一个data_type							paramMap.put("data_type", "m1");						}						List<Map<String, Object>> sysDataList = sysDictMapper.getSysDictDataListByKey(paramMap);						retMap.put(code, sysDataList);						break;					}                }            }        }        else        {            return ResultHelper.getReturnData(retMap, ResultHelper.RET_ERROR, "参数错误!");        }        return ResultHelper.getReturnData(retMap, ResultHelper.RET_SUCCESS, "");    }    /**     * 方法名称: getAbortToMeList 内容摘要: TODO(这里详细描述这个方法的作用)     *     * @param bean     * @param user     * @return     * @author: Baisong     * @time:2020年10月14日 上午11:38:14     */    @Override    public Map<String, Object> getAbortToMeList(FolmAbortToMeBeanVO bean)    {        Map<String, Object> retMap = new HashMap<>();        Map<String, Object> paramMap = new HashMap<>();        //为空        if (bean.getUser_id() == null)        {            return ResultHelper.getReturnData(null, ResultHelper.RET_ERROR, "参数错误!");        }        paramMap.put("user_id", bean.getUser_id());        List<Map<String, Object>> retList = folfinabillDao.getAbortToMeList_M(paramMap);        retMap.put("applyList", retList);        return ResultHelper.getReturnData(retMap, ResultHelper.RET_SUCCESS, "");    }    /**     * 方法名称: getNotificationMessageInfo     * 内容摘要: TODO(获取首页信息)     *     * @return java.util.Map<java.lang.String, java.lang.Object>     * @Param [personnel]     * @Author: wuguoqiang     * @time: 2020/12/10 11:39     **/    @Override    public Map<String, Object> getNotificationMessageInfo(FolFinaBillSearchBeanVO queryInfo, PmPersonnel personnel)    {        Map<String, Object> retMap = new HashMap<>();        Map<String, Object> paramMap = new HashMap<>();        paramMap.put("user_id", personnel.getPersonnel_id());        paramMap.put("dept_personId", personnel.getPersonnel_id());        paramMap.put("sortname", queryInfo.getSortname());        paramMap.put("sortorder", queryInfo.getSortorder());        paramMap.put("pagesize", queryInfo.getPagesize());        paramMap.put("offset", queryInfo.getOffset());        List<Map<String, Object>> list = folfinabillDao.getNotificationMessageInfo(paramMap);        int total = folfinabillDao.getNotificationMessageInfoCount(paramMap);        retMap.put("list", list);        retMap.put("total", total);        Map<String, Object> info = new HashMap<>();        info.put("bank_name", personnel.getPersonnel_bank_title());        info.put("bank_number", personnel.getPersonnel_bankCardCode());        info.put("bank_branch", personnel.getPersonnel_bankName());        info.put("personnel_name", personnel.getPersonnel_name());        info.put("personnel_shortCode", personnel.getPersonnel_shortCode());        info.put("personnel_postName", personnel.getPersonnel_postName());        info.put("personnel_deptName", personnel.getPersonnel_deptName());        info.put("personnel_dept_pname", personnel.getDept_pname());        List<Map<String, Object>> deptList = folfinabillDao.getDeptSInfo(paramMap);        String dept_level_coding = "";        //循环        for (Map<String, Object> map : deptList)        {            //判断            if (map.get("id") != null)            {                //判断                if (!"".equals(dept_level_coding))                {                    dept_level_coding = dept_level_coding + "," + map.get("id").toString();                }                else                {                    dept_level_coding = map.get("id").toString();                }            }            /*//获取部门编码            if (personnel.getPersonnel_deptId() == Integer.parseInt(map.get("ownId").toString()))            {                info.put("dept_level_coding", map.get("id").toString());                break;            }*/        }        //不为空        if (dept_level_coding != null && !"".equals(dept_level_coding))        {            info.put("dept_level_coding", dept_level_coding);        }        retMap.put("info", info);        String num_str = folfinabillDao.getNotificationMessageInfoDetailCountStr(paramMap);        String[] num_arr = num_str.split(",");        info.put("bysb_num", num_arr[0]);        info.put("ywshz_num", num_arr[1]);        info.put("cwshz_num", num_arr[2]);        info.put("dwcl_num", num_arr[3]);        return ResultHelper.getReturnData(retMap, ResultHelper.RET_SUCCESS, "");    }    /**     * 方法名称: signNotificationMessageInfoIsRead     * 内容摘要: TODO(标记已读)     *     * @return java.util.Map<java.lang.String, java.lang.Object>     * @Param [queryInfo]     * @Author: wuguoqiang     * @time: 2020/12/14 14:42     **/    @Override    public Map<String, Object> signNotificationMessageInfoIsRead(FolFinaBillSearchBeanVO queryInfo)    {        Map<String, Object> retMap = new HashMap<>();        Map<String, Object> paramMap = new HashMap<>();        paramMap.put("fol_notification_message_id", queryInfo.getFol_notification_message_id());        int i = 0;        i = folfinabillDao.signNotificationMessageInfoIsRead(paramMap);        //判断        if (i > 0)        {            retMap.put("result", "success");        }        else        {            retMap.put("result", "error");        }        return ResultHelper.getReturnData(retMap, ResultHelper.RET_SUCCESS, "");    }	/**	 * 方法名称: queryAssociatedBankNumber	 * 	 * 内容摘要: TODO(获取联行号)	 * 	 * @param queryInfo	 * @return	 *	 * @author: Baisong	 * @time:2021年6月28日 上午10:15:06	 */	@Override	public Map<String, Object> queryAssociatedBankNumber(FolFinaBillSearchBeanVO queryInfo)	{		Map<String, Object> retMap = new HashMap<>();        Map<String, Object> paramMap = new HashMap<>();        //判断为空        if(queryInfo.getQuery_params_name()==null)        {			return ResultHelper.getReturnData(retMap, ResultHelper.RET_ERROR, "");        }		String[] queryParamsArray = queryInfo.getQuery_params_name().split("、");		paramMap.put("queryParamsArray", queryParamsArray);		paramMap.put("sortname", queryInfo.getSortname());		paramMap.put("sortorder", queryInfo.getSortorder());		paramMap.put("pagesize", queryInfo.getPagesize());		paramMap.put("offset", queryInfo.getOffset());		List<Map<String, Object>> list = folfinabillDao.queryAssociatedBankNumber(paramMap);		retMap.put("result", list);		GridDataBean<Map<String, Object>> bean = new GridDataBean<Map<String, Object>>(queryInfo.getPage(),				folfinabillDao.queryAssociatedBankNumberCount(paramMap), list);		return bean.getGridData();	}	/**	  * @Title: deleteFolApplyBillRelation	  * @Description: 删除审批节点	  * @param 	  * @return void	  * @author: wangyihan	  * @time: 2021年7月14日 上午11:25:54	  * history:	  * 1、2021年7月14日 上午11:25:54 wangyihan 创建方法	  *	 **/	@Transactional	private void deleteFolApplyBillRelationByBillId(FolFinaBillSearchBeanVO queryInfo)	{		Map<String, Object> paramMap = new HashMap<String, Object>();		paramMap.put("fol_fina_bill_id", queryInfo.getFol_fina_bill_id());		this.folApplyBillRelationDao.deleteFolApplyBillRelationByBillId(paramMap);	}	/**	 * 方法名称: getExpenseItemInfo	 * 	 * 内容摘要: TODO(获取费用类型)	 * 	 * @param queryInfo	 * @return	 *	 * @author: Baisong	 * @time:2021年8月9日 上午9:24:25	 */	@Override	public Map<String, Object> getExpenseItemInfo(FolFinaBillSearchBeanVO queryInfo) 	{		Map<String, Object> paramMap = new HashMap<>();		Map<String, Object> retMap = new HashMap<>();		paramMap.put("fol_sys_dict_id", "9");		//判断不为空		if(StringUtils.isNotBlank(queryInfo.getSign_off_authority()))		{			paramMap.put("data_type", queryInfo.getSign_off_authority());			}		//判断不为空		if(StringUtils.isNotBlank(queryInfo.getExpense_item_name()))		{			paramMap.put("value_meaning", queryInfo.getExpense_item_name());		}		List<Map<String, Object>> mapList = sysDictMapper.getSysDictDataListByKey_PC(paramMap);		//判断		if(mapList!=null&&mapList.size()>0) 		{			String expenseItem = "expenseItem";			// 循环			for (Map<String, Object> map : mapList) 			{				String data_type = map.get("data_type") != null ? map.get("data_type").toString() : "";				//判断				if (retMap.containsKey(expenseItem + data_type))				{					List<Map<String, Object>> list = (List) retMap.get(expenseItem + data_type);					list.add(map);				}				else				{					List<Map<String, Object>> list = new ArrayList<>();					list.add(map);					retMap.put(expenseItem + data_type, list);				}			}		}		return retMap;	}	/**	 * 	 * 方法名称: handleCollPayAmount 内容摘要: TODO(计算收付款)	 * 	 * @param applyInfoMap	 *	 * @author: Baisong	 * @time:2021年8月9日 下午5:23:52	 */	public String handleCollPayAmount(Map<String, Object> paramMap)	{		String result="success";		//判断		if (!paramMap.containsKey("fol_fina_bill_subsidiary_id")) 		{			result = "error";			return result;		}		Map<String, Object> applyInfoMap = folfinabillDao.getApplyInfoBySubsidiaryId(paramMap);		BigDecimal coll_pay_amount = BigDecimal.ZERO;		String bill_type = applyInfoMap.get("bill_type").toString();		String reimburse_type = applyInfoMap.get("reimburse_type") != null				? applyInfoMap.get("reimburse_type").toString()				: "";		String charge_off_type = applyInfoMap.get("charge_off_type") != null				? applyInfoMap.get("charge_off_type").toString()				: "";		// 判断是否是报销单 charge_off_type'冲账方式 1 补充打款 2 还借款 3 全额冲账 4累加冲账', 补充打款和还借款需要计算一下		// 可以直接取冲账差额		if ("2".equals(bill_type) && "2".equals(reimburse_type)) 		{			// 补充打款 还借款			if (("1".equals(charge_off_type) || "2".equals(charge_off_type)))          {				coll_pay_amount = new BigDecimal(applyInfoMap.get("charge_off_diff_amount") != null						? applyInfoMap.get("charge_off_diff_amount").toString()						: "0");          }			else if (("3".equals(charge_off_type) || "4".equals(charge_off_type)))          {				coll_pay_amount = BigDecimal.ZERO;          }		}		else 		{			coll_pay_amount = new BigDecimal(					applyInfoMap.get("total_amount") != null ? applyInfoMap.get("total_amount").toString() : "0");		}		FolFinaBillSubsidiary folFinaBillSubsidiary = new FolFinaBillSubsidiary();		folFinaBillSubsidiary.setColl_pay_amount(coll_pay_amount);		folFinaBillSubsidiary.setFol_fina_bill_subsidiary_id(				Integer.valueOf(applyInfoMap.get("fol_fina_bill_subsidiary_id").toString()));		folFinaBillSubsidiaryDao.update(folFinaBillSubsidiary);		return result;      }	/**	 * 方法名称: getLoanChargeOffPayInfo 	 * 	 * 内容摘要: TODO(获取借款单冲账和还款记录)	 * 	 * @param queryInfo	 * @return	 *	 * @author: Baisong	 * @time:2021年8月10日 上午11:30:08	 */	@Override	public Map<String, Object> getLoanChargeOffPayInfo(FolFinaBillSearchBeanVO queryInfo) 	{		Map<String, Object> paramMap = new HashMap<>();		Map<String, Object> retMap = new HashMap<>();		paramMap.put("fol_fina_bill_subsidiary_id", queryInfo.getFol_fina_bill_subsidiary_id());		// folFinaBillSubsidiaryDao		List<Map<String, Object>> loanChargeOfflist = folfinabillDao.getLoanChargeOffInfo(paramMap);		// 循环		for (Map<String, Object> loanChargeOffMap : loanChargeOfflist) 		{			paramMap.put("attachment_module", FOLMsgInfo.FILE_CODE_CWQR);			paramMap.put("fol_id", loanChargeOffMap.get("fol_fina_bill_id"));			paramMap.put("fol_other_id", loanChargeOffMap.get("fol_fina_collection_pay_confirm_id"));			List<Map<String, Object>> fileList = folFileInfoDao.search(paramMap);			loanChargeOffMap.put("fileList", fileList);		}		// folFinaBillSubsidiaryDao		List<Map<String, Object>> loanPaylist = folfinabillDao.getLoanPayInfo(paramMap);		// 循环		for (Map<String, Object> loanPayMap : loanPaylist) 		{			paramMap.put("attachment_module", FOLMsgInfo.FILE_CODE_CWQR);			paramMap.put("fol_id", loanPayMap.get("fol_fina_bill_id"));			paramMap.put("fol_other_id", loanPayMap.get("fol_fina_collection_pay_confirm_id"));			List<Map<String, Object>> fileList = folFileInfoDao.search(paramMap);			loanPayMap.put("fileList", fileList);		}		retMap.put("loanChargeOfflist", loanChargeOfflist);		retMap.put("loanPaylist", loanPaylist);		return retMap;	}		/**	 * 	  * @Title: addApprovalInfoForCWSP	  * @Description: 添加固定审批人：目前为李长余	  * @param 	  * @return void	  * @author: wangyihan	  * @time: 2021年8月12日 下午2:21:10	  * history:	  * 1、2021年8月12日 下午2:21:10 wangyihan 创建方法	  *	 */	private FolApplyBillRelation addApprovalInfoForCWSP(List<FolApplyBillRelation> folApplyList, Integer fol_fina_bill_id)	{		Map<String, Object> paramMap = new HashMap<String, Object>();		paramMap.put("role_num", "folcwsp");		List<PmPersonnel> personnelList = this.pmpersonneldao.getPersonnelByRole(paramMap);				// 判断		if(personnelList != null && personnelList.size() > 0)		{			PmPersonnel personnel = personnelList.get(0);						FolApplyBillRelation relation = new FolApplyBillRelation();			relation.setLevel_index(folApplyList.size() + 1);			relation.setApproval_user_id(personnel.getPersonnel_id());		    relation.setApproval_user_name(personnel.getPersonnel_name());		    relation.setApproval_user_postname(personnel.getPersonnel_postName());		    relation.setApproval_user_deptName(personnel.getPersonnel_deptName());		    relation.setApproval_user_postid(personnel.getPersonnel_postId());		    relation.setApproval_user_deptId(personnel.getPersonnel_deptId());		    relation.setApproval_user_shortcode(personnel.getPersonnel_shortCode());		    relation.setFol_fina_bill_id(fol_fina_bill_id);		    relation.setApproval_state(0);    		relation.setIsPhone("0");		    relation.setLevel_flag("1");			relation.setEnable_flag(1);			relation.setApproval_type("2");						return relation;		}		else		{			return null;		}	}			}